Skip to content

Commit

Permalink
Default to light theme is JS is enabled but not working
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 3, 2024
1 parent c7491b9 commit c6c09d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/noscript.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,13 @@ in src-script.js and main.js
alter their formatting. */

/* Begin theme: light */
:root[data-theme="light"] {
/*
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.
*/
:root[data-theme="light"], :root:not([data-theme]) {
--main-background-color: white;
--main-color: black;
--settings-input-color: #2196f3;
Expand Down

0 comments on commit c6c09d8

Please sign in to comment.