MetaMask / design-tokens

Design tokens to be used throughout MetaMask products
https://metamask.github.io/design-tokens/?path=/docs/getting-started-introduction--docs
Apache License 2.0
28 stars 16 forks source link

feat: add dark/light classname #729

Closed garrettbear closed 2 months ago

garrettbear commented 3 months ago

Description

This PR introduces light and dark class names to CSS variables, associating them with [data-theme="light"] and [data-theme="dark"], respectively. These additions are crucial for enabling the use of CSS variables on mobile platforms and allow theme-specific styling to be applied at the component level. The light class is also necessary to apply a light theme to specific components while the overall theme is set to dark mode, ensuring consistent visual design across different scenarios.

Related issues

Fixes: #728

Manual testing steps

  1. Navigate to a page where theme variables are utilized.
  2. Switch between light and dark themes using the [data-theme] attribute.
  3. Apply the light and dark class names at the component level and verify that the styles are applied correctly.
  4. Confirm that the light class overrides the dark theme for specific components when in dark mode.

Screenshots/Recordings

Before

After

When testing in design-tokens repo you need to add a background default variable so that you can better see the change between light and dark mode. Example below

Screenshot 2024-08-22 at 1 55 03 PM

Video demonstrating data-theme="light", data-theme="dark", .light, and .dark working. Additionally using the class at component level.

https://github.com/user-attachments/assets/c7c6e48a-f827-4194-8067-6a6179747549

Pre-merge author checklist

Pre-merge reviewer checklist

metamaskbot commented 3 months ago

Builds ready [7ac40d6]

Storybook: Storybook