Persist the theme selector choice across page loads #146

Merged
jonny merged 1 commit from feature/persist-theme-choice into develop 2026-10-24 21:24:29 +02:00
Owner

Summary

  • Save an explicit light/dark choice to localStorage (key theme) and remove it when the toggle goes back to system
  • ThemeSelector reads the saved value on load so the right button shows as pressed
  • An inline script at the end of <head> applies the saved color-scheme before first paint, so there's no flash of the system theme on reload
  • Storage access is wrapped in try/catch; if storage is blocked the toggle still works, the choice just doesn't persist
  • Rebuilt JS bundle (app.js, .map, .br, .zst)

Testing

  • npm run lint / npm run build pass; sail test passes (384 tests)
  • Manually checked in Safari: choose dark → navigate → still dark with the button pressed; toggle off → storage cleared and back to light dark

🤖 Generated with Claude Code

## Summary - Save an explicit light/dark choice to `localStorage` (key `theme`) and remove it when the toggle goes back to system - `ThemeSelector` reads the saved value on load so the right button shows as pressed - An inline script at the end of `<head>` applies the saved `color-scheme` before first paint, so there's no flash of the system theme on reload - Storage access is wrapped in try/catch; if storage is blocked the toggle still works, the choice just doesn't persist - Rebuilt JS bundle (`app.js`, `.map`, `.br`, `.zst`) ## Testing - `npm run lint` / `npm run build` pass; `sail test` passes (384 tests) - Manually checked in Safari: choose dark → navigate → still dark with the button pressed; toggle off → storage cleared and back to `light dark` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Save an explicit light/dark choice to localStorage and clear it when
switching back to system. An inline head script applies the saved
colour scheme before first paint to avoid a flash of the system theme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonny merged commit c3cf597950 into develop 2026-10-24 21:24:29 +02:00
jonny deleted branch feature/persist-theme-choice 2026-10-24 21:24:30 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jonny/jonnybarnes.uk!146
No description provided.