-
Notifications
You must be signed in to change notification settings - Fork 30
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
Implement dark mode #9181
Implement dark mode #9181
Conversation
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
cd55c2d
to
1d8be34
Compare
- Uses CSS vars to provide colours - Adds support for dark mode - Adds an example component and story
40f8220
to
9b48ee9
Compare
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.
Wahoo! 🎉
I think it's good to keep the example component and colours until the pattern is well established.
* Creates storybook decorator used to wrap components in an element | ||
* containing the light or dark mode palette colours. | ||
* | ||
* @param colourScheme Choose whether to use the light or darPerformanceNavigation.type palette. |
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 love PerformanceNavigation.type
as much as the next person, but not sure what it’s doing there…
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.
how are you SO eagle eyed
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.
great spot
I ran some numbers, and it’s worth noting that the uncompressed weight of light & dark mode for a complete palette could be just shy of ~9kB. In the absolute worse case scenario of having all 864 formats (8 × 27 & times 4), we could be shipping up to ~7.5MB of CSS. |
What does this change?
As part of a WebX mobbing session, this PR builds upon the proof of concept work set out in #7766 to implement CSS variables to control the palette colours depending on the client colour scheme preference.
This is currently done for
ArticlePage
by adding the CSS variables into emotion'sGlobal
component, already used for some global styling.Dark mode CSS will be loaded for apps if the switch is turned on in frontend (guardian/frontend#26650)
Why?
As part of our DCAR migration, this introduces the pattern to follow to introduce a palette for dark mode into components (resolves #9175)