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

Configure dark mode be the default on page load #48

Open
jdillard opened this issue Oct 5, 2021 · 3 comments
Open

Configure dark mode be the default on page load #48

jdillard opened this issue Oct 5, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@jdillard
Copy link

jdillard commented Oct 5, 2021

As a fan of dark mode, I thought it would be nice to have a configuration option to set dark mode on initial page load. I started looking into how to implement it, but thought I would open a "feature request" just in case.

@jothepro jothepro added the enhancement New feature or request label Oct 8, 2021
@jothepro
Copy link
Owner

jothepro commented Oct 8, 2021

Would you like to always enable dark mode, without providing the toggle button to the user? Or should dark be the default but the user should be allowed to disable it?

@jdillard
Copy link
Author

jdillard commented Oct 8, 2021

The latter. I was thinking something like a config variable that added class="dark-mode" or class="light-mode" to the template and having the javascript check for the class, but I just realized that would require making another manual edit to the templates generated by Doxygen.

@jothepro
Copy link
Owner

jothepro commented Oct 8, 2021

The script in doxygen-awesome-darkmode-toggle.js reads a value from the local storage at page load to determine if it should enable dark mode. You could write a custom script that sets the key prefers-dark-mode-in-light-mode on the users first page visit, remembering if you did so in another key:

if(localStorage.getItem("kilroy-was-here") === null) {
  localStorage.setItem("kilroy-was-here", true)
  localStorage.setItem("prefers-dark-mode-in-light-mode", true)
}

Disclaimer: This is not a decent solution but more of a workaround for your requirement. It does also require the template to be edited (for adding the script). I've not tested if this works, but in my head it does 😉)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants