Dark mode

This commit is contained in:
dingo
2026-04-13 14:31:07 -04:00
parent 218fd0746f
commit e35b14fde1
35 changed files with 372 additions and 77 deletions
+58 -24
View File
@@ -1,8 +1,49 @@
@charset "UTF-8";
:root {
color-scheme: light;
--error-page-bg: #ffffff;
--error-page-text: #242424;
--error-page-muted: #505050;
--error-page-border: #c2c2c2;
--error-header-border: #d6d6d6;
--error-box-bg: #ebebeb;
--error-box-shadow: 0 4px 8px rgba(136, 136, 136, 0.9);
--error-panel-bg: linear-gradient(#d7d7d7, #ebebeb);
--error-danger-bg: linear-gradient(#e97d71, #ca3604);
--error-danger-border: #7d0000;
--error-danger-text: #ffffff;
--error-title: #d03a00;
}
:root[data-theme="dark"] {
color-scheme: dark;
--error-page-bg: #0f1723;
--error-page-text: #e6edf7;
--error-page-muted: #a7b2c3;
--error-page-border: #334155;
--error-header-border: #243244;
--error-box-bg: #1b2636;
--error-box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
--error-panel-bg: linear-gradient(#243244, #1b2636);
--error-danger-bg: linear-gradient(#c95d56, #8f1d14);
--error-danger-border: #e47c73;
--error-danger-text: #fff0ef;
--error-title: #ff8d74;
}
html,
body {
height: 100%;
margin: 0;
}
body {
font-family: Arial, sans-serif;
font-size: 12px;
text-align: center;
background: radial-gradient(circle at top, rgba(216, 86, 53, 0.12), transparent 28%), var(--error-page-bg);
color: var(--error-page-text);
}
h1, h2, h3, h4 {
@@ -12,6 +53,10 @@ h1, h2, h3, h4 {
margin: 0;
}
a {
color: inherit;
}
.header {
margin: auto;
max-width: 960px;
@@ -20,16 +65,11 @@ h1, h2, h3, h4 {
align-items: center;
padding: 0 16px;
box-sizing: border-box;
border-bottom: 1px solid #d6d6d6;
color: #333;
border-bottom: 1px solid var(--error-header-border);
color: var(--error-page-text);
font-size: 22px;
}
html, body {
height: 100%;
margin: 0;
}
.center-box-vertically {
height: 50%;
float: left;
@@ -40,22 +80,18 @@ html, body {
clear: both;
margin: auto;
width: 600px;
background-color: #ebebeb;
border: 1px solid #c2c2c2;
background-color: var(--error-box-bg);
border: 1px solid var(--error-page-border);
border-radius: 5px;
box-shadow: 0 4px 8px #888;
box-shadow: var(--error-box-shadow);
text-align: left;
}
body {
text-align: center;
}
.title {
overflow: hidden;
width: 560px;
padding: 20px;
border-bottom: 1px solid #cccccc;
border-bottom: 1px solid var(--error-page-border);
margin-bottom: 20px;
}
@@ -68,14 +104,13 @@ body {
.title h1 {
font-size: 30px;
color: #d03a00;
color: var(--error-title);
margin-top: 2px;
}
.description {
background-color: #d85635;
border: 1px solid #7d0000;
background: linear-gradient(#e97d71, #ca3604);
border: 1px solid var(--error-danger-border);
background: var(--error-danger-bg);
border-radius: 5px;
padding: 8px;
text-align: center;
@@ -84,14 +119,13 @@ body {
.description h2 {
font-size: 16px;
color: white;
color: var(--error-danger-text);
line-height: 150%;
}
.instructions,
.support {
background-color: #d7d7d7;
background: linear-gradient(#d7d7d7, #ebebeb);
background: var(--error-panel-bg);
border-radius: 5px;
padding: 10px;
margin: 20px;
@@ -110,7 +144,7 @@ body {
.instructions h4,
.support h4 {
font-size: 13px;
color: #505050;
color: var(--error-page-muted);
}
.support span {
@@ -120,7 +154,7 @@ body {
.code h4 {
text-align: right;
font-size: 13px;
color: #505050;
color: var(--error-page-muted);
margin: 0 20px 20px 0;
}
+152 -6
View File
@@ -1,5 +1,7 @@
html {
font-size: 14px;
position: relative;
min-height: 100%;
}
@media (min-width: 768px) {
@@ -8,15 +10,159 @@ html {
}
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
:root {
color-scheme: light;
--app-bg: #f4f7fb;
--app-text: #162033;
--app-muted: #5f6b7a;
--app-surface: #ffffff;
--app-surface-alt: #f8fafc;
--app-border: #d8e0ea;
--app-link: #0d6efd;
--app-link-hover: #0a58ca;
--app-shadow: 0 18px 40px rgba(22, 32, 51, 0.08);
--app-focus-ring: rgba(37, 140, 251, 0.35);
}
html {
position: relative;
min-height: 100%;
:root[data-theme="dark"] {
color-scheme: dark;
--app-bg: #111827;
--app-text: #e5eef9;
--app-muted: #9caecc;
--app-surface: #1a2332;
--app-surface-alt: #121a27;
--app-border: #314055;
--app-link: #7cc4ff;
--app-link-hover: #a6d9ff;
--app-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
--app-focus-ring: rgba(124, 196, 255, 0.35);
}
body {
margin-bottom: 60px;
}
background:
radial-gradient(circle at top, rgba(13, 110, 253, 0.12), transparent 30%),
linear-gradient(180deg, var(--app-surface-alt) 0%, var(--app-bg) 100%);
color: var(--app-text);
transition: background-color 0.2s ease, color 0.2s ease;
}
a {
color: var(--app-link);
}
a:hover,
a:focus {
color: var(--app-link-hover);
}
.container main,
.container footer {
position: relative;
z-index: 1;
}
.theme-toolbar {
position: sticky;
top: 0;
z-index: 1030;
pointer-events: none;
}
.theme-toolbar > div {
pointer-events: auto;
}
.theme-toggle {
border-color: var(--app-border);
background-color: rgba(255, 255, 255, 0.7);
color: var(--app-text);
backdrop-filter: blur(12px);
box-shadow: var(--app-shadow);
}
:root[data-theme="dark"] .theme-toggle {
background-color: rgba(26, 35, 50, 0.82);
}
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
box-shadow: 0 0 0 0.1rem var(--app-surface), 0 0 0 0.25rem var(--app-focus-ring);
}
.btn-outline-secondary {
color: var(--app-text);
border-color: var(--app-border);
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
color: var(--app-text);
background-color: var(--app-surface-alt);
border-color: var(--app-border);
}
.table,
.form-control,
.form-select,
.form-check-input,
.alert,
.card,
.list-group-item,
.modal-content,
.dropdown-menu {
--bs-body-bg: var(--app-bg);
--bs-body-color: var(--app-text);
--bs-border-color: var(--app-border);
--bs-secondary-bg: var(--app-surface-alt);
--bs-tertiary-bg: var(--app-surface-alt);
}
.table,
.form-control,
.form-select,
.alert,
.card,
.list-group-item,
.dropdown-menu {
background-color: var(--app-surface);
color: var(--app-text);
border-color: var(--app-border);
}
.table {
--bs-table-bg: transparent;
--bs-table-color: var(--app-text);
--bs-table-striped-bg: rgba(127, 144, 167, 0.08);
--bs-table-hover-bg: rgba(127, 144, 167, 0.12);
border-color: var(--app-border);
}
.form-control::placeholder {
color: var(--app-muted);
}
.form-text,
.text-muted,
footer.text-muted {
color: var(--app-muted) !important;
}
hr,
.border-top,
.border-bottom {
border-color: var(--app-border) !important;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
background: transparent;
}
+48 -2
View File
@@ -1,4 +1,50 @@
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.
(function () {
const storageKey = "maintenance-theme";
const root = document.documentElement;
const toggle = document.querySelector("[data-theme-toggle]");
const mediaQuery = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
function getPreferredTheme() {
const storedTheme = localStorage.getItem(storageKey);
if (storedTheme === "light" || storedTheme === "dark") {
return storedTheme;
}
return mediaQuery && mediaQuery.matches ? "dark" : "light";
}
function applyTheme(theme) {
root.setAttribute("data-theme", theme);
root.style.colorScheme = theme;
if (toggle) {
const nextTheme = theme === "dark" ? "light" : "dark";
toggle.textContent = theme === "dark" ? "Light mode" : "Dark mode";
toggle.setAttribute("aria-pressed", theme === "dark" ? "true" : "false");
toggle.setAttribute("title", "Switch to " + nextTheme + " mode");
}
}
applyTheme(getPreferredTheme());
if (toggle) {
toggle.addEventListener("click", function () {
const nextTheme = root.getAttribute("data-theme") === "dark" ? "light" : "dark";
localStorage.setItem(storageKey, nextTheme);
applyTheme(nextTheme);
});
}
if (mediaQuery) {
mediaQuery.addEventListener("change", function (event) {
if (localStorage.getItem(storageKey)) {
return;
}
applyTheme(event.matches ? "dark" : "light");
});
}
})();