Skip to content
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

Merged
merged 6 commits into from
Mar 29, 2022
Merged

[Badge] Simplify unstyled API #31974

merged 6 commits into from
Mar 29, 2022

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Mar 24, 2022

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

@michaldudak michaldudak changed the title [Badge] [Badge] Simplify unstyled API Mar 24, 2022
@mui-bot
Copy link

mui-bot commented Mar 24, 2022

Details of bundle changes

@material-ui/unstyled: parsed: -0.67% 😍, gzip: -0.62% 😍

Generated by 🚫 dangerJS against 4955b39

@michaldudak michaldudak marked this pull request as ready for review March 24, 2022 13:13
@michaldudak michaldudak requested review from mnajdova and hbjORbj March 24, 2022 13:13
@michaldudak michaldudak added component: badge This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Mar 24, 2022
/** 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);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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 =
Copy link
Member

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.

Copy link
Member Author

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.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 25, 2022
Copy link
Member

@mnajdova mnajdova left a 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);
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: badge This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BadgeUnstyled] Unstyled API shape discussion
3 participants