MetaMask / design-tokens

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

feat: adding data theme light attribute to stylesheet to provide dyna… #627

Closed georgewrmarshall closed 6 months ago

georgewrmarshall commented 6 months ago

Description

This PR addresses the need for flexible theme switching, as discussed in Issue #626. The motivation behind this change is to enhance user experience by allowing dynamic theme changes (light and dark modes) at any level of the application.

The solution involves updating our CSS to explicitly define light and dark mode variables and applying them using the data-theme attribute. This approach ensures that theme changes are seamlessly reflected across the application, regardless of the global theme setting.

Related issues

Fixes: #626

Manual testing steps

  1. Run storybook in the extension using yarn storybook
  2. Inspect the stylesheet of the design tokens and add ,[data-theme='light'] to root
  3. Test the theme switch at a component level by manually adding data-theme="light" or data-theme="dark" to component containers.

Screenshots/Recordings

After

Screencast below shows theming not work but once the data attribute [data-theme='light'] dynamic theming works

https://github.com/MetaMask/design-tokens/assets/8112138/7dc71a2a-1685-4c0b-8bfb-259d483630f6

Pre-merge author checklist

Pre-merge reviewer checklist