-
Notifications
You must be signed in to change notification settings - Fork 390
feature: dynamic prefers color scheme #12465
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
Conversation
e0ee0bb to
1ff7663
Compare
update ref remove language about it not being dynamic, due to quarto-dev/quarto-cli#12465
|
I think this is good to merge! |
update ref remove language about it not being dynamic, due to quarto-dev/quarto-cli#12465
|
This has an annoying interaction with the visual toggle. Right now they both "win" in the sense that changing the OS setting always changes the appearance when It's like a 1-bit CRDT problem. I see three ways to make them consistent:
1 is simplest, but you can't ever get out once you've clicked the toggle, without going into dev tools and deleting the local storage key. I think 2 is my favorite but it's slightly complicated to implement and document. 3 is simple but kind of weird and hard to explain. |
|
Huh, yeah, this is all a bit weird. I wonder what other SSGs that have dark-light mode do in this case... |
|
According to The Complete Guide to the Dark Mode Toggle
This is option 1 and the simplest. It's consistent with what currently happens on page load. I think I'll do this, and we can consider if we want to be more respectful of the user's OS setting in the future. |
it's the same as the visual toggle except we don't set local storage
we set quarto-light or quarto-dark at the end of this script, with the correct setting. so there is no need to set it here.
also, exhaustively test visual toggle
|
From a code review standpoint, this PR adds two more entries to Is this okay? |
also, the localAlternateSentinel is used dynamically so it needs to be updated when we detect an OS change so that the toggle works on the first click
1ff7663 to
71d9248
Compare
|
I'll go ahead merge this, and ask my code review question on Thursday. Glad to go back and clean this up later. |
update ref remove language about it not being dynamic, due to quarto-dev/quarto-cli#12465
This is a case of "it was easier to fix this than to document it the way it is".
We can watch the media query
prefers-color-schemein exactly the same way we watch the visual toggle.This does not introduce any new FOUC. However we still have a FOUC on some browsers when toggling dark mode dynamically #12309.This turns out to be aquarto previewissue.I am hesitant to merge this, but it would make documenting
respect-user-color-schememuch easier if we don't have to say it's only on page load and not dynamic.First let's see if tests pass. I have added a bunch of them in this PR.