[FIX] Detect dark mode in a wider range of sphinx themes#201
Open
SamAdamDay wants to merge 2 commits intoexecutablebooks:masterfrom
Open
[FIX] Detect dark mode in a wider range of sphinx themes#201SamAdamDay wants to merge 2 commits intoexecutablebooks:masterfrom
SamAdamDay wants to merge 2 commits intoexecutablebooks:masterfrom
Conversation
|
I came across same issue this suppose to solve, would love for this to be merged <3! |
|
This solution works. It would be great to have this merged into the main branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CSS file currently uses
body[data-theme="dark"]to detect whether the theme is using dark mode. But different Sphinx themes use different mechanisms for marking this.Here is a summary of the mechanisms used by all the themes in https://sphinx-themes.org/ which are currently building and which support dark mode.
body[data-theme="dark"]andbody[data-theme="auto"]html[data-mode="dark"]andhtml[data-mode="auto"]html[data-mode="dark"]andhtml[data-mode="auto"]body.theme-dark. The auto mode either sets this orbody.theme-lighthtml[data-mode="dark"]andhtml[data-mode="auto"]html.dark. The auto mode either sets this class or removes ithtml.dark. The auto mode either sets this class or removes itmediaattribute of stylesheetlinkelements to toggle these stylesheets on and off. Supporting this would require some JavaScript hacking.mediaattribute of stylesheetlinkelements to toggle these stylesheets on and off. Supporting this would require some JavaScript hacking.body.theme-dark. There's no auto modeOverall there are five different mechanisms. This PR enables detecting dark mode in the four cases where this can be done using pure CSS.
Fixes #193
Fixes #194
Fixes #195