Skip to content
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

Merged
merged 3 commits into from Nov 19, 2021
Merged

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Nov 18, 2021

This PR fixes several issues regarding CSS variables APIs.

createCssVarsProvider

  • vars should be merged (before was using replace) from all color schemes
  • add colorSchemes to theme for referencing color values

getInitColorSchemeScript

  • add single quote and fix misuse variables
  • add tests

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 18, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 9d58b1d

@siriwatknp siriwatknp marked this pull request as ready for review November 18, 2021 06:26
@siriwatknp siriwatknp added the package: system Specific to @mui/system label Nov 18, 2021
},
dark: {
palette: {
grey: '#888',
Copy link
Member

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',
          }....
          .....
                ```

Copy link
Member Author

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;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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".

@siriwatknp siriwatknp merged commit 80c8795 into mui:master Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants