Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve display of clippy lints page when JS is disabled #13585

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions util/gh-pages/index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ <h1>Clippy Lints</h1> {# #}

<noscript> {# #}
<div class="alert alert-danger" role="alert"> {# #}
Sorry, this site only works with JavaScript! :( {# #}
Lints search and filtering only works with JS enabled. :( {# #}
</div> {# #}
</noscript> {# #}

<div> {# #}
<div class="panel panel-default"> {# #}
<div class="panel panel-default" id="menu-filters"> {# #}
<div class="panel-body row"> {# #}
<div id="upper-filters" class="col-12 col-md-5"> {# #}
<div class="btn-group" id="lint-levels" tabindex="-1"> {# #}
Expand Down
17 changes: 16 additions & 1 deletion util/gh-pages/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ details[open] {
}

/* Expanding the mdBook theme*/
.light {
.light, body:not([class]) {
--inline-code-bg: #f6f7f6;
}
.rust {
Expand All @@ -220,6 +220,21 @@ details[open] {
--inline-code-bg: #191f26;
}

@media (prefers-color-scheme: dark) {
body:not([class]) {
/*
In case JS is disabled and the user's system is in dark mode, we take "coal" as default
dark theme.
*/
--inline-code-bg: #1d1f21;
}
}

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