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

mkdocs: add light/dark mode toggle #3637

Merged
merged 4 commits into from Nov 7, 2022
Merged

Conversation

aSemy
Copy link
Contributor

@aSemy aSemy commented Nov 5, 2022

@aSemy aSemy marked this pull request as draft November 5, 2022 10:51
@@ -27,7 +27,7 @@ body, input {
font-family: cash-market, "Helvetica Neue", helvetica, sans-serif;
line-height: normal;
font-weight: bold;
color: #353535;
color: var(--md-default-fg-color)
Copy link
Contributor Author

@aSemy aSemy Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means the header colour dynamically changes between light/dark mode

Before the colour of headers is hardcoded to be grey, even in dark mode:

image

After, using the var, the colour will dynamically change:
image

image

The full set of css vars that mkdocs provide are available here: https://github.com/squidfunk/mkdocs-material/blob/2569d4f0884b9fe3be934215ce0cfddf8efc94b8/src/assets/stylesheets/main/_colors.scss

@aSemy aSemy marked this pull request as ready for review November 5, 2022 11:01
Copy link
Collaborator

@hfhbd hfhbd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@aSemy aSemy marked this pull request as draft November 5, 2022 12:40
@aSemy aSemy marked this pull request as ready for review November 5, 2022 12:40
@hfhbd
Copy link
Collaborator

hfhbd commented Nov 5, 2022

Is it possible to use the media query to auto-switch to light/dark mode? Don't know, if other people would want this behavior too.

@aSemy
Copy link
Contributor Author

aSemy commented Nov 5, 2022

Is it possible to use the media query to auto-switch to light/dark mode? Don't know, if other people would want this behavior too.

The settings in this PR should evaluate the browser preferences to select the correct mode https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#system-preference

If you're asking about auto-switching based on time-of-day, the docs say that's not a publically available feature yet

@hfhbd
Copy link
Collaborator

hfhbd commented Nov 5, 2022

Yes, I mean this nice but private feature. But I am fine with the current publicly available feature.

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

Successfully merging this pull request may close these issues.

None yet

4 participants