Add light/dark theme toggle
CSS custom properties overridden via [data-theme="dark"] with prefers-color-scheme fallback. Toggle in nav persists choice to localStorage. No Go changes — CSS and template only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,46 @@
|
||||
--code-bg: #f0ede4;
|
||||
--green: #4a7c40;
|
||||
--blue: #3b5998;
|
||||
--error-bg: #fdf0f0;
|
||||
--error-border: #e8c4c4;
|
||||
}
|
||||
|
||||
/* Dark theme — explicit toggle */
|
||||
[data-theme="dark"] {
|
||||
--bg: #1a1a1a;
|
||||
--bg-alt: #242420;
|
||||
--text: #d4d0c8;
|
||||
--text-dim: #999;
|
||||
--text-lt: #666;
|
||||
--accent: #d44040;
|
||||
--accent-h: #e85050;
|
||||
--border: #3a3a36;
|
||||
--border-lt: #2e2e2a;
|
||||
--code-bg: #2a2a24;
|
||||
--green: #6aac58;
|
||||
--blue: #5b89c8;
|
||||
--error-bg: #2a1a1a;
|
||||
--error-border: #4a2a2a;
|
||||
}
|
||||
|
||||
/* Dark theme — system preference fallback */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html:not([data-theme]) {
|
||||
--bg: #1a1a1a;
|
||||
--bg-alt: #242420;
|
||||
--text: #d4d0c8;
|
||||
--text-dim: #999;
|
||||
--text-lt: #666;
|
||||
--accent: #d44040;
|
||||
--accent-h: #e85050;
|
||||
--border: #3a3a36;
|
||||
--border-lt: #2e2e2a;
|
||||
--code-bg: #2a2a24;
|
||||
--green: #6aac58;
|
||||
--blue: #5b89c8;
|
||||
--error-bg: #2a1a1a;
|
||||
--error-border: #4a2a2a;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
@@ -82,6 +122,20 @@ code {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
.theme-toggle {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
padding: 0.25rem;
|
||||
line-height: 1;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
.theme-toggle:hover {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Page containers
|
||||
@@ -147,9 +201,9 @@ code {
|
||||
Alerts
|
||||
=========================== */
|
||||
.error {
|
||||
background: #fdf0f0;
|
||||
background: var(--error-bg);
|
||||
color: var(--accent);
|
||||
border: 1px solid #e8c4c4;
|
||||
border: 1px solid var(--error-border);
|
||||
padding: 0.625rem 1rem;
|
||||
border-radius: 3px;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
Reference in New Issue
Block a user