chore: update design tokens for preferred color scheme#814
chore: update design tokens for preferred color scheme#814georgewrmarshall wants to merge 3 commits intomainfrom
Conversation
Co-authored-by: george.marshall <george.marshall@consensys.net>
|
Cursor Agent can help with this pull request. Just |
📖 Storybook Preview |
| @media (prefers-color-scheme: dark) { | ||
| :root:not([data-theme]) { |
There was a problem hiding this comment.
@cursoragent should we also add not .dark and same for light theme?
There was a problem hiding this comment.
I refined the CSS selectors for system preference-based themes to prevent conflicts with explicitly set themes. This ensures that themes applied via data-theme attributes or .dark/.light classes take precedence over system preferences, improving theme consistency.
- I modified the CSS selectors within the
@media (prefers-color-scheme: ...)blocks inpackages/design-tokens/src/css/dark-theme-colors.cssandpackages/design-tokens/src/css/light-theme-colors.css. - Specifically, I updated the
:rootselector from:root:not([data-theme])to:root:not([data-theme]):not(.dark):not(.light). - This change ensures that system preference-based themes are only applied when no explicit theme is set via the
data-themeattribute or the.darkor.lightclasses on the:rootelement, preventing unintended theme overrides.
Learn more about Cursor Agents
Co-authored-by: george.marshall <george.marshall@consensys.net>
📖 Storybook Preview |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
📖 Storybook Preview |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Description
data-themeattribute is set, as reported in MetaMask/metamask-design-system#452. Previously, the light theme was the default, leading to incorrect theming for users with dark mode system preferences.prefers-color-schememedia queries.:rootselector has been removed to prevent it from being the unconditional default.@media (prefers-color-scheme: light)and@media (prefers-color-scheme: dark)queries are added to apply the respective themes automatically based on the user's system preference.@media (prefers-color-scheme: no-preference)is included, defaulting to the light theme for backward compatibility.[data-theme='light'],[data-theme='dark'],.light, and.darkselectors retains higher priority.Related issues
Fixes: #452
Manual testing steps
data-themeattribute is explicitly set on thehtmlorbodyelement.data-theme="light"ordata-theme="dark"to thehtmlelement and verify that the theme is forced, overriding the system preference.Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist