Skip to content

Add dark mode with system preference detection and manual toggle#154

Closed
rodchristiansen wants to merge 2 commits intograhamgilbert:masterfrom
rodchristiansen:feature/dark-mode
Closed

Add dark mode with system preference detection and manual toggle#154
rodchristiansen wants to merge 2 commits intograhamgilbert:masterfrom
rodchristiansen:feature/dark-mode

Conversation

@rodchristiansen
Copy link

Adds a dark/light theme to the web UI that automatically follows the OS preference (prefers-color-scheme) and lets users manually override via a toggle button in the navbar. Selection persists in localStorage.

Behavior

  • Auto (default): follows OS dark/light preference; updates live when system preference changes
  • Manual: clicking the toggle cycles auto → light → dark → auto
  • Persistence: preference stored in localStorage under crypt-theme
  • No flash: theme-toggle.js is loaded in <head> so the theme applies before page renders

Changes

  • site_static/dark-mode.css — CSS custom property theming for all UI components (tables, navbar, modals, forms, DataTables, badges, code blocks). Both [data-theme="dark"] and @media (prefers-color-scheme: dark) paths.
  • site_static/theme-toggle.js — toggle logic, localStorage persistence, system preference listener, accessible aria-label
  • templates/base.html — links the dark mode stylesheet, loads the toggle script in <head>, adds the toggle button (moon/sun icons) to the navbar

No server-side changes

Fully client-side. No new dependencies, no Django changes, no database migrations.

rodchristiansen and others added 2 commits March 2, 2026 20:27
Implements dark/light mode theme switching with:
- CSS custom properties for consistent theming
- Automatic system preference detection (prefers-color-scheme)
- Manual toggle button in navbar
- localStorage persistence of user preference
- Smooth transitions between themes

New files:
- site_static/dark-mode.css - Theme variables and styled components
- site_static/theme-toggle.js - Toggle logic and persistence

Modified:
- templates/base.html - Add dark mode CSS, toggle script, and navbar button
Changes:
- Default to 'auto' mode (no localStorage set) to follow system theme
- Toggle cycles: auto -> light -> dark -> auto
- Show 'A' badge on toggle button when in auto mode
- System preference changes apply immediately in auto mode
- Added aria-labels for accessibility
Copilot AI review requested due to automatic review settings March 3, 2026 05:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@grahamgilbert
Copy link
Owner

Thanks for this, but we’re moving away from the python codebase in #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants