Skip to content

Add light/dark theme toggle; show the order card only after a result

Aiho Tehisaru requested to merge feature/theme-toggle into trunk

What

  • Theme toggle in the header (moon/sun icon). Defaults to the OS preference; the first click stores an explicit choice in localStorage (kolo-theme). A data-theme attribute, applied by a tiny head script before first paint, overrides prefers-color-scheme in both directions, so there is no flash of the wrong theme. color-scheme is set per theme so native controls follow. Blocked storage degrades to a non-persistent toggle.
  • Order Colocation card is now rendered hidden and shown only while the calculated price (#output) is visible. It hides again on empty input or errors. No KOLO_ORDER_URL still means no card at all.
  • No external resources. Audited the page: system font stack, inline CSS/JS and inline SVG only, nothing to vendor. Added a test so a CDN script, webfont or stylesheet can't sneak in later.

Testing

  • TDD: new tests in internal/api/api_test.go (toggle markup, CSS selectors, head script before <style>, hidden order card, no external refs), seen failing first. go test ./... passes.
  • Real browser check (headless Chromium, 23 assertions): OS light/dark, toggle both ways, persistence across reload, no flash, blocked localStorage, order card visible only with a result (hidden on clear and on validation error), zero external requests, no console errors. Visually checked both themes at phone width.

Not changed

No API, config or Go runtime changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NbAi9mrm1Gj3oN6JyW3TRU

Merge request reports

Loading