Skip to content

Commit 5b2f4ee

Browse files
authored
[fix] prefers-color-scheme: use dark theme if body[data-theme="auto"] (#154)
Before this patch the CSS implementation assumes that "dark" is supported by the theme if the `data-theme` attribute of the <body> tag is unset. Since most themes are using "light" colors (compare https://sphinx-themes.org) and do not set `data-theme` it is better to assume light is the default, even when the browser setting `prefers-color-scheme: dark`! BTW: remove duplication of styles from dark/light theme that are already set in the common style. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
1 parent 154f273 commit 5b2f4ee

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

sphinx_tabs/static/tabs.css

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,18 @@
5555
/* Dark theme preference styling */
5656

5757
@media (prefers-color-scheme: dark) {
58-
body:not([data-theme="light"]) .sphinx-tabs-panel {
58+
body[data-theme="auto"] .sphinx-tabs-panel {
5959
color: white;
6060
background-color: rgb(50, 50, 50);
6161
}
6262

63-
body:not([data-theme="light"]) .sphinx-tabs-tab {
63+
body[data-theme="auto"] .sphinx-tabs-tab {
6464
color: white;
65-
font-size: 16px;
66-
font-weight: 400;
6765
background-color: rgba(255, 255, 255, 0.05);
6866
}
6967

70-
body:not([data-theme="light"]) .sphinx-tabs-tab[aria-selected="true"] {
71-
font-weight: 700;
72-
border: 1px solid #a0b3bf;
68+
body[data-theme="auto"] .sphinx-tabs-tab[aria-selected="true"] {
7369
border-bottom: 1px solid rgb(50, 50, 50);
74-
margin: -1px;
7570
background-color: rgb(50, 50, 50);
7671
}
7772
}
@@ -85,16 +80,10 @@ body[data-theme="dark"] .sphinx-tabs-panel {
8580

8681
body[data-theme="dark"] .sphinx-tabs-tab {
8782
color: white;
88-
font-size: 16px;
89-
font-weight: 400;
90-
border: 1px solid rgba(255, 255, 255, 0.15);
9183
background-color: rgba(255, 255, 255, 0.05);
9284
}
9385

9486
body[data-theme="dark"] .sphinx-tabs-tab[aria-selected="true"] {
95-
font-weight: 700;
96-
border: 1px solid #a0b3bf;
9787
border-bottom: 2px solid rgb(50, 50, 50);
98-
margin: -1px;
9988
background-color: rgb(50, 50, 50);
10089
}

0 commit comments

Comments
 (0)