Skip to content

Commit

Permalink
Handle noscript style with "js" class on <html>.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 1, 2024
1 parent ca5c6f6 commit ac764df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion util/gh-pages/index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<link id="styleNight" rel="stylesheet" href="https://rust-lang.github.io/mdBook/tomorrow-night.css" disabled="true"> {# #}
<link id="styleAyu" rel="stylesheet" href="https://rust-lang.github.io/mdBook/ayu-highlight.css" disabled="true"> {# #}
<link rel="stylesheet" href="style.css"> {# #}
<noscript><link rel="stylesheet" href="noscript.css"></noscript> {# #}
</head> {# #}
<body> {# #}
<script src="theme.js"></script> {# #}
Expand Down
3 changes: 0 additions & 3 deletions util/gh-pages/noscript.css

This file was deleted.

5 changes: 5 additions & 0 deletions util/gh-pages/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ details[open] {
}
}

html:not(.js) #settings-dropdown,
html:not(.js)#menu-filters {
display: none;
}

#settings-dropdown {
position: absolute;
margin: 0.7em;
Expand Down
4 changes: 4 additions & 0 deletions util/gh-pages/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function setTheme(theme, store) {
}

(function() {
// This file is loaded first. If so, we add the `js` class on the `<html>`
// element.
document.documentElement.classList.add("js");

// loading the theme after the initial load
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
const theme = loadValue("theme");
Expand Down

0 comments on commit ac764df

Please sign in to comment.