-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[material-ui][Button] Deprecate composed classes for v6 #40675
Conversation
Netlify deploy previewBundle size reportDetails of bundle changes (Toolpad) |
'colorPrimary', | ||
'colorSecondary', | ||
'colorSuccess', | ||
'colorError', | ||
'colorInfo', | ||
'colorWarning', |
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.
new classes
@@ -149,6 +268,7 @@ const buttonClasses: ButtonClasses = generateUtilityClasses('MuiButton', [ | |||
'fullWidth', | |||
'startIcon', | |||
'endIcon', | |||
'icon', |
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.
new class
Got it!! thanks for the update |
@DiegoAndai since option 1 is choosen for above RFC, I'm assuming no change is required in this PR |
@sai6855 correct! No change is required. We'll keep this PR on hold for a little longer as per this comment: #40417 (comment) |
Hey @sai6855, we're now unblocked: #40417 (comment) |
replacementSelector: '.MuiButton-icon.MuiButton-sizeMedium', | ||
replacementSelectorPrefix: '& .', |
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.
Shouldn't the replacement be &.MuiButton-sizeMedium .MuiButton-icon
?
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.
from my understanding, iconSizeMedium
is split into icon
and sizeMedium
, both these classes are applied to icon
slot and not root
slot. But your suggestion seems to add sizeMedium
class to root slot. Am i right or did i misunderstood your question?
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.
The size
classes are applied to the root: https://mui.com/material-ui/api/button/#button-classes-sizeLarge
So to replace the .MuiButton-iconSizeMedium
class, we need to select .MuiButton-sizeMedium .MuiButton-icon
: An element with class MuiButton-icon
within an element with class MuiButton-sizeMedium
. We might want to use the direct child selector .MuiButton-sizeMedium > .MuiButton-icon
.
[`&.${buttonClasses.sizeMedium}${" > "}.${buttonClasses.icon}`]: { | ||
color: 'red', | ||
}, | ||
[`&.${buttonClasses.sizeLarge}${" > "}.${buttonClasses.icon}`]: { |
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.
tried transforming to &.${buttonClasses.sizeLarge} > .${buttonClasses.icon}
but couldn't succeed. Does this tranformtion works or shall try again?
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.
It should work if you add ' > '
to the quasis
(here) instead of the expressions
when modifying the template literal. The quasis
are the chunks of the template string that are not within ${}
.
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.
Done, PR is ready for review
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.
Looks good @sai6855!
Only have two comments left
packages/mui-codemod/src/deprecations/button-classes/button-classes.test.js
Show resolved
Hide resolved
packages/mui-codemod/src/deprecations/button-classes/test-cases/actual.js
Outdated
Show resolved
Hide resolved
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.
Great job @sai6855!
part of #40417
preview: https://deploy-preview-40675--material-ui.netlify.app/material-ui/api/button/#classes
migration guide: https://deploy-preview-40675--material-ui.netlify.app/material-ui/migration/migrating-from-deprecated-apis/#button