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 theme #40

Open
mad-briller opened this issue Dec 17, 2021 · 2 comments
Open

Dark mode theme #40

mad-briller opened this issue Dec 17, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@mad-briller
Copy link
Contributor

mad-briller commented Dec 17, 2021

Hey there, me again!

It would be great if Doctum supported a dark mode theme out of the box.

Many modern documentation sites etc. ship with the ability for either the user to toggle the theme or for it to respect the user's preference using the prefers-color-scheme media query.

Would this be difficult to achieve in Doctum by default? I looked into the css in use and it seems that the theme was generated using a bootstrap theme generation utility, it would be possible to generate an alternate theme that is dark and then swap these out at run-time, but you would lose the ability to use the media query provide the user with their preference.

Another approach is to replace all color values with css variables and re-assigning those inside the media query:

:root {
  --bg-primary: #fff;
 }
 
@media (prefers-color-scheme: dark) {
  :root {
  --bg-primary: #000;
 }
}

This secondary approach would probably require a lot more work as it would require changing the theme generated by the external tool, and making everything a css variable, but it would provide the best user experience and require no javascript to modify classes or swap out script tags.

Let me know if you have any thoughts, and thanks for your time.

@williamdes williamdes added the enhancement New feature or request label Dec 17, 2021
@williamdes
Copy link
Member

Hey, thank you for letting me know !

I bet a 3third solution would be overriding colors for each element in a @media (prefers-color-scheme: dark) { query in the main css file. To be tried ;)

https://caniuse.com/?search=prefers-color-scheme

@williamdes williamdes self-assigned this Dec 17, 2021
@williamdes
Copy link
Member

This is some start to make something correct

@media (prefers-color-scheme: dark) {
    body {
        background-color: #242222;
    }
    #control-panel {
        background: #242222;
    }
    #api-tree {
        background: linear-gradient(to bottom, #242222, #242222 50%, #303133 50%, #303133);
        background-size: 100% 56px;
        color: #fff;
    }
    #api-tree a {
        color: #fff;
    }
    #site-nav.navbar-default {
        background-color: #242222;
    }
    #site-nav.navbar-default .navbar-brand,
    #site-nav.navbar-default .navbar-nav > li > a {
        color: #fff;
    }
}

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

No branches or pull requests

2 participants