Skip to content

[material-ui] Migrate components to support CSS extraction#42001

Merged
siriwatknp merged 66 commits intomui:nextfrom
siriwatknp:mui/css-extraction-2
May 6, 2024
Merged

[material-ui] Migrate components to support CSS extraction#42001
siriwatknp merged 66 commits intomui:nextfrom
siriwatknp:mui/css-extraction-2

Conversation

@siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Apr 22, 2024

Use styled-v6 codemod + edge case manual adjustment for the rest of the components in #41273

@siriwatknp siriwatknp added scope: dialog Changes related to the dialog. scope: drawer Changes related to the drawer. component: Icon The React component. scope: menu Changes related to the menu. scope: paper Changes related to the <Paper>. scope: toast Changes related to the toast. scope: tabs Changes related to the tabs. scope: tooltip Changes related to the tooltip. scope: speed dial Changes related to the speed dial. package: material-ui labels Apr 22, 2024
@siriwatknp siriwatknp requested review from brijeshb42 and mnajdova May 2, 2024 07:33
transformLibraries: ['local-ui-lib'],
sourceMap: true,
displayName: true,
overrideContext: (context) => {
Copy link
Member Author

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

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Contributor

@o-alexandrov o-alexandrov May 6, 2024

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

@siriwatknp siriwatknp requested a review from DiegoAndai May 3, 2024 11:19
@siriwatknp siriwatknp force-pushed the mui/css-extraction-2 branch from e4f4831 to 279e4cc Compare May 3, 2024 11:42
@siriwatknp siriwatknp added component: LoadingButton The React component. scope: typography Changes related to typography. scope: link Changes related to the link. labels May 3, 2024
Copy link
Member

@DiegoAndai DiegoAndai left a 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

indeterminateIcon: indeterminateIconProp = defaultIndeterminateIcon,
inputProps,
size = 'medium',
disableRipple = false,
Copy link
Member

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?

Copy link
Member Author

@siriwatknp siriwatknp May 6, 2024

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: {} },
]

transformLibraries: ['local-ui-lib'],
sourceMap: true,
displayName: true,
overrideContext: (context) => {
Copy link
Member

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

ref={ref}
{...other}
style={{
...other.style,
Copy link
Member

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.

{...other}
ownerState={ownerState}
style={{
...other.style,
Copy link
Member

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.

{...other}
style={{
...(variant === 'elevation' && {
'--Paper-shadow': (theme.vars || theme).shadows[elevation],
Copy link
Member

@oliviertassinari oliviertassinari Jun 23, 2024

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:

Suggested change
'--Paper-shadow': (theme.vars || theme).shadows[elevation],
'--MuiPaper-shadow': (theme.vars || theme).shadows[elevation],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Icon The React component. component: LoadingButton The React component. component: TablePagination The React component. scope: dialog Changes related to the dialog. scope: drawer Changes related to the drawer. scope: link Changes related to the link. scope: menu Changes related to the menu. scope: paper Changes related to the <Paper>. scope: skeleton Changes related to the skeleton. scope: speed dial Changes related to the speed dial. scope: tabs Changes related to the tabs. scope: text field Changes related to the text field. scope: toast Changes related to the toast. scope: tooltip Changes related to the tooltip. scope: typography Changes related to typography. v6.x

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants