Add light/dark mode toggle for the UI

The UI stylesheet already centralized its palette in a :root block, so this
mostly meant (1) migrating the ~30 colors still hardcoded in rules into
variables so they flip in one place, and (2) adding a [data-theme="dark"]
override palette. Artifact rendering is untouched — those use the separate
static/themes/*.css and the preview backdrop stays white by design, since
artifacts (charts, reports) are authored light.

- Toggle lives in the gear-menu dropdown (Dark mode / Light mode), persists
  to localStorage.
- A tiny inline script in each page <head> (feed, settings, login) applies
  the stored theme before first paint, so dark-mode users never see a white
  flash on load.
- color-scheme: dark on the dark palette makes native form controls
  (inputs, buttons) render dark too.
- Semantic accents (kept=green, shared=blue, today, danger) got
  dark-appropriate variants; status/data-viz colors (usage bar, tag chips)
  and the white artifact backdrop are intentionally left as-is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
peter 2026-09-02 17:14:56 +01:00
parent c9edac62cf
commit 9a3b381f39
5 changed files with 145 additions and 35 deletions

View file

@ -5,6 +5,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Settings — AgentFeed</title>
<link rel="stylesheet" href="/static/daybook.css">
<script>
// Set the theme before first paint so dark-mode users never see a light flash.
(function () {
try {
if (localStorage.getItem("daybook.theme") === "dark") {
document.documentElement.setAttribute("data-theme", "dark");
}
} catch (e) {}
})();
</script>
</head>
<body>
{% include "artifacts/_topbar.html" %}