just-the-docs icon indicating copy to clipboard operation
just-the-docs copied to clipboard

add support for 'prefers-color-scheme' save our eyes @ night

Open Alexander-Taran opened this issue 3 years ago • 7 comments

Please consider changing the world of github pages and other consumers of template to save our vision. (-:

Alexander-Taran avatar Jun 09 '22 18:06 Alexander-Taran

@pdmosses could I get your opinion on how this impacts your Combination PR + the general dark mode work that you've done?

mattxwang avatar Jun 14 '22 23:06 mattxwang

@mattxwang the Combination PR #578 doesn't include automatic switching because #464 and #560 are alternative ways of fixing issue #234, and I didn't know which would finally be merged.

In contrast to #464 and #560, the present PR doesn't update the color scheme on open pages until they are manually reloaded, I think? It's also not configurable.

Perhaps issue #234 is the best place to discuss the pros and cons of the alternative PRs.

pdmosses avatar Jun 16 '22 19:06 pdmosses

It is not configurable. Yes. Changes are automatic. Although IE will not get any styling (-: It also does not take into account that users can use their own "template"

I proposed this as a way. I think that absence of window.matchMedia might be a feature detection fallback to this technique to support the non-evergreen browsers instead to append a style tag to head with no media-query.

Alexander-Taran avatar Jun 16 '22 20:06 Alexander-Taran

Okay, I think that this is

  • part of a larger discussion
  • not likely to be merged into v0.4.0, until we decide on the discussion

I'm going to label this PR as needs discussion. I'm not particularly well-versed in how JTD handles dark mode and will need to do a bit more reading; if another maintainer wants to take point on leading the color theme discussion, that would be great.

mattxwang avatar Jul 05 '22 00:07 mattxwang

Thoughts: 2 themes are there since the time when browsers did not support relative media query So site author could decide on the theme. Most of the sites using JTD are using one of default themes.. Providing auto-switching theme as a default and explaining in the docs how to force ones own theme is a better solution because out of the box most sites (that use defaults) will care about night mode..

Alexander-Taran avatar Jul 29 '22 06:07 Alexander-Taran

I tried running this PR in my fork and noticed that it is necessary to modify this script

In https://github.com/simonebortolin/just-the-docs/tree/prefers-color-scheme

I have made a fix for the script that after the change in question at this PR no longer works

simonebortolin avatar Aug 31 '22 19:08 simonebortolin

Left a comment in https://github.com/just-the-docs/just-the-docs/issues/234 explaining what's necessary to get this in a mergeable state! Happy to have anybody take it on, and I can review it, etc.

mattxwang avatar Sep 15 '22 00:09 mattxwang