feat: proper dark-mode support via color-scheme meta + light-dark() #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "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?
Adds proper dark-mode support following https://olliewilliams.xyz/blog/dark-mode/.
What changed
color-schememeta tag as source of truth —<meta name="color-scheme" content="light dark">in<head>; the OS preference is respected before CSS loads, and form controls / scrollbars / system colors now follow the theme.light-dark()everywhere — every themed color is declared once in:root, replacing the duplicated light/dark variable blocks,bodytheme classes, andprefers-color-schememedia queries.<head>restores the saved choice (kept the existingthemelocalStorage key, so existing visitors' saved preferences survive) and sets the mode class on<html>pre-paint, so the toggler icon doesn't flash either.light/dark, orlight dark+ cleared storage for system; same 3-way cycle as before..hide-in-{light,dark}-themenow key off the resolved scheme via a registered--used-schemecustom property + container style queries (prefers-color-schemeonly reflects the OS setting, ignoring the toggle).Verification
Headless Chromium (Playwright), 26 assertions, all passing:
light-dark()resolves on arbitrary elements (drives form controls)"system"value from the old implementation still parsesNote
light-dark()requires a 2024+ browser (Chrome 123, Firefox 120, Safari 17.5). Older browsers get UA default colors.static/styles.cssis untracked — rebuild viamake buildbeforemake publish.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKabGxxNaNoocaxN8B4BFG