-
Notifications
You must be signed in to change notification settings - Fork 131
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
dark/light body class #1780
base: main
Are you sure you want to change the base?
dark/light body class #1780
Conversation
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.
This is inconsistent with how we’ve (currently) implemented Generators.dark; the two should definitely be consistent — and ideally using the same code.
It also feels a little overkill to me to use the probe transition technique in production when we only expect to need it (versus a media listener) because the stylesheets can change during development. Perhaps we could use a conditional NODE_ENV test inside of Generators.dark. I know I’ve also advised to minimize the differences between production and development, but if it’s entirely hidden within the Generators.dark implementation, that seems pretty safe. Or we could just always do the probe transition technique…
I've come to believe that the media listener is only one of the top-level mechanisms that allow the page to decide what mode it is in. Other mechanisms are: ignoring the preferred media (ok), enforcing the color mode via a toggle (not a best practice, but can be useful for developers), changing the mode based on an arbitrary computation (good for artists and fun). In all these cases the styles should set a correct This I think implies that the current node’s (computed) So, I need to modify Generators.dark, and see how to use it so that it also sets the class. |
to wrap into #1762 if that's the best course of action |
This adds a
dark
orlight
class on the body to reflect thecolor-scheme
property set by css.For the rationale: we can't access the
color-scheme
property through css; only the browser can do that. I don't know why it's like that, and find it irritating. This "fixes" it somehow, and allows to create styles such as:.dark .warning { border: 1px solid red }
which are otherwise impossible to do.
This is also necessary to support dark mode properly with tailwind (#1762).