-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support "prefers-color-scheme" #559
Comments
Definitely looks interesting. I'll probably wait on adding this until there's an official spec, but if there's a PR for adding support before then I'd be happy to take a look. |
These links may be useful for this (you can try this add-on in Firefox for testing too) : |
It doesn't seem like this constitutes an "official" specification, but the CSS Working Group's Media Queries Level 5 Editor's Draft contains |
This should fix <iv-org#559>. The cookie storage format has been changed from boolean ("true"/"false") to tri-state ("dark"/"light"/""), so that users without a cookie set will get dark mode if they have enabled the dark theme in their operating system. The code for handling the cookie state, along with the user's operating system theme, has been factored out into a new function `update_mode`, which is called both at window load and at the "storage" event listener, because the "storage" event listener is only trigerred when a change is made to the localStorage from another tab/window (for more info - see <https://stackoverflow.com/a/4679754>).
* Add prefers-color-scheme support This should fix <#559>. The cookie storage format has been changed from boolean ("true"/"false") to tri-state ("dark"/"light"/""), so that users without a cookie set will get dark mode if they have enabled the dark theme in their operating system. The code for handling the cookie state, along with the user's operating system theme, has been factored out into a new function `update_mode`, which is called both at window load and at the "storage" event listener, because the "storage" event listener is only trigerred when a change is made to the localStorage from another tab/window (for more info - see <https://stackoverflow.com/a/4679754>).
Although not much supported (yet), this would switch Invidious to the dark theme automatically when the browser indicates a dark color scheme is preferred (e.g. on Linux when the user has a dark system theme).
In time this could probably remove the need for a toggle between light and dark mode entirely. For now I would have the setting have a 3rd option "auto" which is the light theme when "prefers-color-scheme" is not supported, or the preferred theme when it is supported. This option should probably be the default.
The text was updated successfully, but these errors were encountered: