Skip to content

Commit 8ecedb9

Browse files
committed
Add support for dark theme
The themes which support light/dark themes for example, furo and pydata-sphinx-theme tend to set an attribute in either <html> or <body> tag. We can opt for a darker selection background colour. It could be #0c6100 - dark green #745315 dark yellow: we use this!
1 parent 5e6fa8f commit 8ecedb9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

sphinx_lesson/_static/sphinx_lesson.css

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
/* sphinx_lesson.css */
1+
/* sphinx_lesson.css
2+
* https://webaim.org/resources/contrastchecker/?fcolor=00000&bcolor=FCE762
3+
* */
24
:root {
3-
--sphinx-lesson-selection-bg-color: #fce762;
4-
--sphinx-lesson-selection-fg-color: #000000;
5+
--sphinx-lesson-selection-bg-color: #fce762;
6+
--sphinx-lesson-selection-fg-color: #000000;
7+
}
8+
9+
/* https://webaim.org/resources/contrastchecker/?fcolor=FFFFFF&bcolor=745315
10+
* when dark theme is selected the some themes use this attirbute
11+
*/
12+
html[data-theme='dark'], body[data-theme='dark'] {
13+
--sphinx-lesson-selection-bg-color: #745315;
14+
--sphinx-lesson-selection-fg-color: #ffffff;
15+
}
16+
17+
/* when browser/system theme is dark and no theme is selected */
18+
@media (prefers-color-scheme: dark) {
19+
html[data-theme='auto'], body[data-theme='auto'] {
20+
--sphinx-lesson-selection-bg-color: #745315;
21+
--sphinx-lesson-selection-fg-color: #ffffff;
22+
}
523
}
624

725
body.wy-body-for-nav img.with-border {

0 commit comments

Comments
 (0)