-
-
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
[docs] Add theme.applyStyles
and migrate docs
#42498
Conversation
Netlify deploy preview
Bundle size report |
sx={[ | ||
{ | ||
overflow: 'auto', | ||
}, | ||
flexBasis | ||
? { | ||
flexBasis: `${flexBasis}px`, | ||
} | ||
: { | ||
flexBasis: null, | ||
}, | ||
]} |
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.
Are all of these sx ternary stuff related to the PR's goal or should we keep it separate? Also, I'm curious why this approach is better than the previous one 🤔
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.
Ideally, it can be a separate PR. It was updated due to the sx
codemod (also transforming theme.palette.mode
condition).
I'm curious why this approach is better than the previous one 🤔
It's compatible with Pigment CSS. If you don't mind, I can update the sx prop docs in this PR altogether.
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.
Ah cool! I'm slightly sad as this syntax is way uglier than the previous one 😅 but it feels all right to update the docs in a dedicated PR. Maybe it's worth highlighting these things (why these ternaries were picked up and missing tasks) in the PR's description, though!
@@ -31,14 +31,12 @@ export default function ExampleCollapsibleList() { | |||
'--joy-palette-text-secondary': '#635e69', | |||
'--joy-palette-primary-plainColor': '#d48cff', | |||
}, | |||
|
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 think a saw a PR for fix this, but in case it was unrelated, we shouldn't transform these lines.
This is fixed, I missed the default color primary. |
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 on the latest netlify build, not sure what was the issue. |
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 can't find anything else, I think we can merge and fix any regression in case we missed something. Awesome job Jun, both on the codemod and the migration 🤩
Heya! @siriwatknp found a place where it seems like the new way to write conditional styles isn't working properly: https://next--material-ui.netlify.app/experiments/docs/demos/ — the toolbar
|
This is a codemod bug, I will open a fix today. |
let Root = 'span'; | ||
if (shape === 'inline') { | ||
Root = InlineShape; | ||
} | ||
if (shape === 'image') { | ||
Root = ImageShape; | ||
} | ||
/* eslint-disable material-ui/no-hardcoded-labels, react/no-danger */ | ||
return ( | ||
<Root shape={shape === 'inline' ? 'inline' : adShape} className={className}> | ||
<Root className={className}> |
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 logic isn't equivalent. I have opened to fix this: #42735.
Docs update
Before:
After:
The recommended approach for styling dark mode is to use
theme.applyStyles('dark', …)
and stop usingtheme.palette.mode === 'dark'
check to smoothly migrate to Pigment CSS.This PR includes the migration of the docs using codemods with manual adjustments. The changes are huge but I don't think we can avoid it.