Skip to content

Commit 28598ad

Browse files
jmacotclaude
andcommitted
feat: add auto dark mode to password template
Auto-detects dark mode via system preference and time of day (21h–7h). Respects localStorage theme from other tools. Adds Sistema A dark variables, header gradient override, and prefers-reduced-motion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cb53815 commit 28598ad

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

password_template.html

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>/*[|template_title|]*/0</title>
7-
<meta name="theme-color" content="#1a3a5c">
7+
<meta name="theme-color" id="meta-theme" content="#0f172a">
88

99
<!-- do not cache this page -->
1010
<meta http-equiv="cache-control" content="max-age=0">
@@ -29,6 +29,19 @@
2929
--radius: 20px;
3030
--radius-lg: 24px;
3131
}
32+
[data-theme="dark"] {
33+
--bg: #0f172a;
34+
--surface: #1e293b;
35+
--border: #334155;
36+
--ink: #f1f5f9;
37+
--ink-muted: #94a3b8;
38+
--accent: #93c5fd;
39+
--accent-hover: #bae0ff;
40+
--red: #f87171;
41+
--red-light: #3b1010;
42+
--shadow: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15);
43+
--shadow-hover: 0 25px 50px -12px rgb(0 0 0 / 0.3);
44+
}
3245
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
3346
body {
3447
font-family: 'DM Sans', sans-serif;
@@ -303,10 +316,28 @@
303316
50% { opacity: 0.4; }
304317
}
305318

319+
/* ── Dark mode overrides ── */
320+
[data-theme="dark"] .login-header {
321+
background: linear-gradient(135deg, #152238 0%, #1c2f4a 50%, #213656 100%);
322+
border-bottom: 1px solid rgba(255,255,255,0.08);
323+
box-shadow: 0 4px 24px rgba(0,0,0,0.3);
324+
}
325+
[data-theme="dark"] .input-wrap input:focus {
326+
box-shadow: 0 0 0 3px rgba(147,197,253,0.15);
327+
}
328+
[data-theme="dark"] .btn-submit { color: #0f172a; }
329+
306330
@media (max-width: 600px) {
307331
.login-header { padding: 36px 24px 32px; }
332+
.login-header::before, .login-header::after { display: none; }
308333
.login-body { padding: 24px 20px; }
309334
}
335+
@media (prefers-reduced-motion: reduce) {
336+
*, *::before, *::after {
337+
animation-duration: 0.01ms !important;
338+
transition-duration: 0.01ms !important;
339+
}
340+
}
310341
</style>
311342
</head>
312343
<body>
@@ -456,6 +487,42 @@ <h1>/*[|template_title|]*/0</h1>
456487
}, 3000);
457488
}
458489
});
490+
491+
// ─────────────────────────────────────────────
492+
// DARK MODE (auto-detect)
493+
// ─────────────────────────────────────────────
494+
(function() {
495+
function applyTheme(dark) {
496+
var metaTheme = document.getElementById('meta-theme');
497+
if (dark) {
498+
document.documentElement.setAttribute('data-theme', 'dark');
499+
if (metaTheme) metaTheme.setAttribute('content', '#152238');
500+
} else {
501+
document.documentElement.removeAttribute('data-theme');
502+
if (metaTheme) metaTheme.setAttribute('content', '#0f172a');
503+
}
504+
}
505+
function getAutoTheme() {
506+
var hour = new Date().getHours();
507+
var prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
508+
return (hour >= 21 || hour < 7 || prefersDark) ? 'dark' : 'light';
509+
}
510+
var saved = localStorage.getItem('theme');
511+
var savedDate = localStorage.getItem('theme-date');
512+
var today = new Date().toDateString();
513+
if (saved && savedDate === today) {
514+
applyTheme(saved === 'dark');
515+
} else {
516+
applyTheme(getAutoTheme() === 'dark');
517+
}
518+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function() {
519+
var s = localStorage.getItem('theme');
520+
var sd = localStorage.getItem('theme-date');
521+
if (!s || sd !== new Date().toDateString()) {
522+
applyTheme(getAutoTheme() === 'dark');
523+
}
524+
});
525+
})();
459526
</script>
460527
</body>
461528
</html>

0 commit comments

Comments
 (0)