Skip to content
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

Closed
PureTryOut opened this issue May 28, 2019 · 3 comments · Fixed by #601
Closed

Support "prefers-color-scheme" #559

PureTryOut opened this issue May 28, 2019 · 3 comments · Fixed by #601
Labels
enhancement Improvement of an existing feature help wanted Extra attention is needed

Comments

@PureTryOut
Copy link

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.

@omarroth omarroth added the enhancement Improvement of an existing feature label May 29, 2019
@omarroth
Copy link
Contributor

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.

@omarroth omarroth added the help wanted Extra attention is needed label May 29, 2019
@lionirdeadman
Copy link

@psvenk
Copy link
Contributor

psvenk commented Jun 18, 2019

It doesn't seem like this constitutes an "official" specification, but the CSS Working Group's Media Queries Level 5 Editor's Draft contains prefers-color-scheme: https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-scheme

omarroth pushed a commit to psvenk/invidious that referenced this issue Aug 15, 2019
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>).
omarroth pushed a commit that referenced this issue Aug 15, 2019
* 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>).
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of an existing feature help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants