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
[system] Fix minor CssVars issues #29747
Conversation
}, | ||
dark: { | ||
palette: { | ||
grey: '#888', |
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.
Given such theme, can we add a test to check theme.vars.palette.primary
is equal to the value of selected color scheme?
colorSchemes: {
light: {
palette: {
primary: '#000',
},
},
dark: {
palette: {
primary: '#888',
}....
.....
```
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 other test already covers that, so I think we are good.
@@ -5,15 +5,15 @@ export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme'; | |||
export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme'; | |||
|
|||
export default function getInitColorSchemeScript(options?: { | |||
defaultMode?: 'light' | 'dark' | 'system'; | |||
enableSystem?: boolean; |
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.
Just for my understanding, what does this boolean represent?
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 script is run before the browser render HTML. By specifying enableSystem: true
, it will set the mode to user preference.
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.
'light' | 'dark' | 'system' does not make sense because it is about "do you want to use system preference or not".
This PR fixes several issues regarding CSS variables APIs.
createCssVarsProvider
vars
should be merged (before was using replace) from all color schemescolorSchemes
to theme for referencing color valuesgetInitColorSchemeScript