feat: auto OS-driven dark mode (prefers-color-scheme) #8
Reference in New Issue
Block a user
Delete Branch "feat/auto-dark-mode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the cross-project automatic dark-mode feature for nanodrop (item 2026-05-11 in ~/features.md).
What changed
src/views/layout.ts— added<meta name="color-scheme" content="light dark">to <head> so browser UA chrome (scrollbars, form-control popups, initial backdrop) matches the user's system theme before the stylesheet parses (prevents the white-flash on dark OS).public/style.css— full refactor to CSS custom properties. Light palette under:root, dark palette under@media (prefers-color-scheme: dark). 17 semantic tokens (--bg,--bg-elevated,--bg-hover,--fg,--fg-muted,--fg-on-accent,--border-color,--border-subtle,--accent,--accent-hover,--danger,--danger-bg,--danger-fg,--input-bg,--input-bg-focus,--input-fg,--input-border). Removed the floating#fff5f5literal — nowvar(--danger-bg).tests/integration/style.test.ts(+3 assertions) — locks in the@media (prefers-color-scheme: dark)block, the presence of core--bg/--fg/--accenttokens, and the absence of hex literals outside:root/@media.tests/integration/pages.test.ts(+1 assertion) — verifies the meta tag is emitted in served HTML.No toggle UI. No localStorage. No cookie. No per-account preference. Pure media-query driven, per the user's explicit spec.
Second commit (
refactor:) restores thevar(--border)shorthand in 3 rules for consistency — byte-equivalent at the CSS cascade.Verification
npx tsc --noEmitclean.npm run buildclean.font-size: 16pxstill oninput[type=text|password|file]atpublic/style.css:184.--dangeron--danger-bgat ≈4.85:1).Security
None. Presentation-only diff: meta tag is a static string literal (no user-data interpolation),
escHtml(title)preserved, no auth/IDOR/injection/XSS surface change, zero newprocess.envreads.Environment
None. No new/renamed/removed env vars. Pure client-side
prefers-color-scheme— no server-side configuration.