-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Badge] Simplify unstyled API #31974
Conversation
@material-ui/unstyled: parsed: -0.67% 😍, gzip: -0.62% 😍 |
/** State class applied to the badge `span` element if `invisible={true}`. */ | ||
invisible: string; | ||
} | ||
|
||
export type BadgeUnstyledClassKey = keyof BadgeUnstyledClasses; | ||
|
||
export function getBadgeUtilityClass(slot: string): string { | ||
return generateUtilityClass('MuiBadge', slot); | ||
return generateUtilityClass('MuiBadgeUnstyled', slot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to add a BREAKING CHANGE
section in the PR description and the label on the PR, so that we don't forget to list it in the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we had discussion around what should the classnames look like, but I don't remember why and how we got to the decision. I wouldn't use Unstyled
in the name of the classes, as the classes are using for styling, once you add styles for the classname is not unstyled anymore :) We should maybe re-think the names of the classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we agreed it's necessary for the styled and unstyled components to have different classnames, so their styles can be overridden independently. Perhaps using Mui*
for Material UI and Base*
for Base components would work better? Also, when we have the means to modify/disable these classes, I would not include Base classes in Material UI components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Base
as a prefix sounds great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forget to change the prefix using Base
instead of Unstyled
let displayValue; | ||
|
||
if (variant !== 'dot') { | ||
displayValue = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated with the logic inside useBadge
. Should we maybe just propagate null/undefined in the badgeContent
if the variant is dot? I don't think there is need to process the displayValue
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this logic from useBadge
- it doesn't know about the variant anymore as it's a purely visual prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last comment around the base classname (also we should update the PR description to match the new classname prefix)
/** State class applied to the badge `span` element if `invisible={true}`. */ | ||
invisible: string; | ||
} | ||
|
||
export type BadgeUnstyledClassKey = keyof BadgeUnstyledClasses; | ||
|
||
export function getBadgeUtilityClass(slot: string): string { | ||
return generateUtilityClass('MuiBadge', slot); | ||
return generateUtilityClass('MuiBadgeUnstyled', slot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forget to change the prefix using Base
instead of Unstyled
Remove appearance-related props from BadgeUnstyled.
@mui/material's Badge should not have any observable changes, other than addition of
BaseBadge-
CSS classes.Closes #31868