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

Dark mode toggle #302

Closed
wants to merge 2 commits into from
Closed

Dark mode toggle #302

wants to merge 2 commits into from

Conversation

aronsommer
Copy link

Hi Patrick

I have added a dark mode toggle button (aux link) in the upper right.

You can preview it here if you like:

https://aronsommer.github.io/just-the-docs-dmt/

I have used the scripts from here:

https://medium.com/@derekkedziora/how-to-add-a-dark-mode-toggle-to-a-jekyll-site-a76dac00128d

Have a nice day!

Aron

@runxel
Copy link

runxel commented May 22, 2020

Also @ the maintainers:
What speaks against prefers-color-scheme? Should be the right and semantic way to do so nowadays. (:

@pmarsceill
Copy link
Collaborator

I think it should definitely be optional, as you could write your own color_scheme that is neither dark nor light -- in which case you may not want to enable a toggle or the prefers-color-scheme css. Additionally we have changed the way theming works so any code written before 0.2.9 will likely need to be updated.

@pdmosses
Copy link
Contributor

#464 provides a light-or-dark color scheme option, which uses media queries to switch between the built-in light and dark color schemes. That supports automatically following the system-level setting, but it does not provide a button to toggle the scheme independently, so it should not conflict with this PR.

As @pmarsceill mentioned, the appearance of a toggle button would need to be configurable, and not appear by default; but that would be easy to fix. The current conflicts with the latest release of the theme also need to be resolved.

@pdmosses pdmosses mentioned this pull request Oct 18, 2020
pdmosses added a commit to pdmosses/just-the-docs that referenced this pull request Apr 14, 2021
The JS code is mostly copied from https://derekkedziora.com/blog/dark-mode, following PR just-the-docs#302. Configurability enhancements:
- toggle between custom schemes
- toggle automatically on system preference changes
- display button on all pages or just one
- change button text
This addition should be backwards compatible: the added features are activated only when the toggle configuration options are used.
@mattxwang mattxwang added the status: needs discussion Issues that need more discussion before they can be properly triaged. label Jul 20, 2022
@aronsommer aronsommer closed this by deleting the head repository Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs discussion Issues that need more discussion before they can be properly triaged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants