-
-
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
[zero] Export extendTheme
for creating a zero-runtime theme
#40897
Conversation
Netlify deploy previewhttps://deploy-preview-40897--material-ui.netlify.app/ @material-ui/core: parsed: +0.15% , gzip: +0.16% Bundle size reportDetails of bundle changes (Toolpad) |
3c892e8
to
3558d4d
Compare
3558d4d
to
badff46
Compare
extendTheme
for zero runtime.extendTheme
for zero runtime
extendTheme
for zero runtimeextendTheme
for zero runtime
deba513
to
1760d6c
Compare
extendTheme
for zero runtimeextendTheme
for creating a theme
@@ -1,75 +1,3 @@ | |||
:root { |
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.
Moved to theme in next.config.js
…em/extract-theme
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!
I appreciate the clarity of the readme!
); | ||
``` | ||
|
||
The `extendTheme` utility will go through the theme and create a `vars` object which represents the tokens that refer to CSS variables. |
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 I understand correctly, extendTheme
is optional.
When should it be used? What are the benefits compared to the plain theme?
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.
Thanks for the questions.
extendTheme is optional (I will mention it in the doc)
You would use it if you want zero-runtime to generate CSS variables from the theme.
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.
You would use it if you want zero-runtime to generate CSS variables from the theme.
Is there some added value for the user in doing so?
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 allows you to support multiple colorSchemes/themes and access css variables as JS object in your runtime code, ie, you could also do this in your code -
import theme from '@mui/zero-runtime/theme';
function Component() {
return <div style={{[theme.vars.palette.primary.main]: 'red'}} />
}
which would output
<div style="--mui-palette-primary-main: red"></div>
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
@samuelsycamore @danilo-leal I'd love to hear feedbacks on the docs from both of you. FYI, I'd like to keep this PR simple so added only the basic things for the docs to get started. We could add more docs, like advanced usage, tutorial, technical explanation in a separate PR. |
Co-authored-by: Matt <[email protected]> Signed-off-by: Siriwat K <[email protected]>
extendTheme
for creating a themeextendTheme
for creating a theme with zero runtime
…em/extract-theme
extendTheme
for creating a theme with zero runtimeextendTheme
for creating a zero-runtime theme
Changes
theme
or using theextendTheme
util to generate CSS variables/dark mode supportWhat's next
To keep this PR small, I decided to do these in the next PR: