diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-04-03 14:11:01 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-04-03 14:27:19 +0200 |
| commit | 2edc54c830bb3925967c77486fef32707b4321ce (patch) | |
| tree | 9ac7a4fcb121ea52b0f12657448e7885efdccaca | |
| parent | c7491b97331afb79189d029c7ae7554010a2b187 (diff) | |
| download | rust-2edc54c830bb3925967c77486fef32707b4321ce.tar.gz rust-2edc54c830bb3925967c77486fef32707b4321ce.zip | |
Default to light theme is JS is enabled but not working
| -rw-r--r-- | src/librustdoc/html/static/css/noscript.css | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/css/noscript.css b/src/librustdoc/html/static/css/noscript.css index f425f3ec95c..ccb97d7df4c 100644 --- a/src/librustdoc/html/static/css/noscript.css +++ b/src/librustdoc/html/static/css/noscript.css @@ -34,7 +34,7 @@ nav.sub { in rustdoc.css */ /* Begin theme: light */ -:root { +:root, :root:not([data-theme]) { --main-background-color: white; --main-color: black; --settings-input-color: #2196f3; @@ -140,7 +140,7 @@ nav.sub { @media (prefers-color-scheme: dark) { /* Begin theme: dark */ - :root { + :root, :root:not([data-theme]) { --main-background-color: #353535; --main-color: #ddd; --settings-input-color: #2196f3; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 9993dfb1d8c..0bb073b1cea 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -2315,8 +2315,14 @@ in src-script.js and main.js tooling to ensure different themes all define all the variables. Do not alter their formatting. */ +/* +About `:root:not([data-theme])`: if for any reason the JS is enabled but cannot be loaded, +`noscript` won't be enabled and the doc will have no color applied. To do around this, we +add a selector check that if `data-theme` is not defined, then we apply the light theme +by default. +*/ /* Begin theme: light */ -:root[data-theme="light"] { +:root[data-theme="light"], :root:not([data-theme]) { --main-background-color: white; --main-color: black; --settings-input-color: #2196f3; |
