-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Migrate components to support CSS extraction #42001
Conversation
@@ -104,6 +111,26 @@ const pigmentOptions = { | |||
transformLibraries: ['local-ui-lib'], | |||
sourceMap: true, | |||
displayName: true, | |||
overrideContext: (context) => { |
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.
A workaround for mui/pigment-css#10
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.
Adding this here fixes the issue? Should this then be made part of the library itself?
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.
Yes, I can confirm that this prevents the error. I added here just to be a workaround but if you think it should be a part of Pigment, I am happy to add it. However, I think it should be a separate package for integrating with MUI system, not a part of nextjs/vite plugin.
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.
If this would be required for every project that uses Material UI and Pigment CSS, we should make it part of the library. Do we know why it is required tough? Maybe we are fixing a symptom, not the problem
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.
probably related issue: mui/pigment-css#8
e4f4831
to
279e4cc
Compare
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.
Amazing job with the codemod Jun, congrats 🎉
I just have some comments but they're not blockers, LGTM
@@ -117,6 +117,7 @@ const Checkbox = React.forwardRef(function Checkbox(inProps, ref) { | |||
indeterminateIcon: indeterminateIconProp = defaultIndeterminateIcon, | |||
inputProps, | |||
size = 'medium', | |||
disableRipple = false, |
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.
What's with this change?
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.
Otherwise, variants
won't work because disabled=undefined
variants: [
{ props: { color: 'default', disableRipple: false } }, style: { … } },
]
@@ -104,6 +111,26 @@ const pigmentOptions = { | |||
transformLibraries: ['local-ui-lib'], | |||
sourceMap: true, | |||
displayName: true, | |||
overrideContext: (context) => { |
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.
If this would be required for every project that uses Material UI and Pigment CSS, we should make it part of the library. Do we know why it is required tough? Maybe we are fixing a symptom, not the problem
@@ -107,6 +113,22 @@ const Paper = React.forwardRef(function Paper(inProps, ref) { | |||
className={clsx(classes.root, className)} | |||
ref={ref} | |||
{...other} | |||
style={{ | |||
...other.style, |
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 should come last, props' style should override the predefined CSS vars if needed.
@@ -137,6 +175,10 @@ const Typography = React.forwardRef(function Typography(inProps, ref) { | |||
className={clsx(classes.root, className)} | |||
{...other} | |||
ownerState={ownerState} | |||
style={{ | |||
...other.style, |
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.
Same here, this should come last.
@@ -107,6 +113,22 @@ const Paper = React.forwardRef(function Paper(inProps, ref) { | |||
className={clsx(classes.root, className)} | |||
ref={ref} | |||
{...other} | |||
style={{ | |||
...(variant === 'elevation' && { | |||
'--Paper-shadow': (theme.vars || theme).shadows[elevation], |
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.
We should prefix this variable no? --Paper-shadow
feels like one that would easily conflict. If we match the values in the theme:
'--Paper-shadow': (theme.vars || theme).shadows[elevation], | |
'--MuiPaper-shadow': (theme.vars || theme).shadows[elevation], |
Use
styled-v6
codemod + edge case manual adjustment for the rest of the components in #41273