-
-
Notifications
You must be signed in to change notification settings - Fork 5
chore: update design tokens for preferred color scheme #814
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
base: main
Are you sure you want to change the base?
chore: update design tokens for preferred color scheme #814
Conversation
Co-authored-by: george.marshall <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cursoragent should we also add not .dark and same for light 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.
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.css
andpackages/design-tokens/src/css/light-theme-colors.css
. - Specifically, I updated the
:root
selector 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-theme
attribute or the.dark
or.light
classes on the:root
element, preventing unintended theme overrides.
Learn more about Cursor Agents
Co-authored-by: george.marshall <[email protected]>
📖 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-theme
attribute 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-scheme
media queries.:root
selector 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.dark
selectors retains higher priority.Related issues
Fixes: #452
Manual testing steps
data-theme
attribute is explicitly set on thehtml
orbody
element.data-theme="light"
ordata-theme="dark"
to thehtml
element and verify that the theme is forced, overriding the system preference.Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist