Skip to content

Commit 6167675

Browse files
authored
Reduce flashing on page load (#359)
Currently, this is done by setting the background to the theme preference (light/dark). This will stop working once we have a switch to toggle between light and dark mode. It was tempting to move the JS to executing earlier, but it needs to be executed once the document elements are in place (for shortcuts etc.).
1 parent 028f302 commit 6167675

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
File renamed without changes.

assets/theme-css/dark-mode.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/* Dark mode is now defined in pydata-sphinx-theme CSS */
2+
/* See html[data-theme='light'] and html[data-theme='dark'] */
3+
4+
/* This CSS is to override the background to dark, if that is the browser preference,
5+
instead of defaulting to light mode rendering. */
6+
7+
@media (prefers-color-scheme: dark) {
8+
html:not([data-theme]) {
9+
--pst-color-background: #14181e;
10+
}
11+
}
12+
13+
/* Once our colors have all been mapped to PST color names, this section can be removed. */
114
@media (prefers-color-scheme: dark) {
215
:root {
316
/* Basically, we reassign the colors named in the non-dark theme. The

layouts/_default/baseof.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
{{ if .Site.Params.footer }}
3636
{{ partial "footer.html" . -}}
3737
{{ end }}
38-
39-
{{ partial "javascript.html" . -}}
40-
{{ partial "analytics.html" . -}}
4138
</body>
39+
{{ partial "javascript.html" . -}}
40+
{{ partial "analytics.html" . -}}
4241
</html>

0 commit comments

Comments
 (0)