feat(ui): theme quick-toggle in the sidebar footer (LC-292) #324

Merged
longjacksonle merged 1 commit from feat/lc-292-theme-quick-toggle into main 2026-06-14 20:51:42 +02:00

Summary

One-click theme toggle in the sidebar footer: flip light<->dark without opening Settings, persisted across reloads and devices.

Changes

  • server/templates/base.html: window.__lcToggleTheme in the no-flash bootstrap. Reads the resolved data-theme, flips dark<->light within the same contrast family (light<->dark, hc-light<->hc-dark), applies instantly via __lcSetTheme, and fire-and-forget POSTs to persist.
  • server/src/routes/settings.rs: POST /settings/theme (post_theme, AuthUser-gated). Saves only users.theme, returns 204, and stamps Set-Cookie: lc-theme=<v>; Max-Age=31536000; SameSite=Lax so the next navigation has no flash-of-old-theme. Invalid value falls back to "system" (no 500).
  • server/src/routes/mod.rs: register the route.
  • server/templates/partials/sidebar.html: footer button data-lc-theme-toggle.
  • server/locales/{en,es}/partials.ftl: sidebar-toggle-theme (Toggle theme / Cambiar tema).

High-contrast and system remain on the Settings appearance picker (the quick-toggle is the common case, not the full picker).

Testing

  • just check, just fmt, just test, just test-saas all pass.
  • New server/tests/routes_settings_theme.rs: valid theme persists + sets cookie; hc-dark accepted; invalid value falls back to system (no 500); unauthenticated POST 303s to /login.

Not operator-visible (no env/config/contract change).

## Summary One-click theme toggle in the sidebar footer: flip light<->dark without opening Settings, persisted across reloads and devices. ## Changes - `server/templates/base.html`: `window.__lcToggleTheme` in the no-flash bootstrap. Reads the resolved `data-theme`, flips dark<->light within the same contrast family (`light`<->`dark`, `hc-light`<->`hc-dark`), applies instantly via `__lcSetTheme`, and fire-and-forget POSTs to persist. - `server/src/routes/settings.rs`: `POST /settings/theme` (`post_theme`, `AuthUser`-gated). Saves only `users.theme`, returns 204, and stamps `Set-Cookie: lc-theme=<v>; Max-Age=31536000; SameSite=Lax` so the next navigation has no flash-of-old-theme. Invalid value falls back to "system" (no 500). - `server/src/routes/mod.rs`: register the route. - `server/templates/partials/sidebar.html`: footer button `data-lc-theme-toggle`. - `server/locales/{en,es}/partials.ftl`: `sidebar-toggle-theme` (Toggle theme / Cambiar tema). High-contrast and system remain on the Settings appearance picker (the quick-toggle is the common case, not the full picker). ## Testing - `just check`, `just fmt`, `just test`, `just test-saas` all pass. - New `server/tests/routes_settings_theme.rs`: valid theme persists + sets cookie; hc-dark accepted; invalid value falls back to system (no 500); unauthenticated POST 303s to /login. Not operator-visible (no env/config/contract change).
feat(ui): theme quick-toggle in the sidebar footer (LC-292)
All checks were successful
check-secrets / Nosey parker (push) Successful in 7s
check-secrets / Kingfisher (push) Successful in 8s
check-secrets / TruffleHog (push) Successful in 8s
check-secrets / TruffleHog (pull_request) Successful in 4s
check-secrets / Kingfisher (pull_request) Successful in 5s
check-secrets / Nosey parker (pull_request) Successful in 5s
Create release / Create release from merged PR (pull_request) Has been skipped
Check / clippy + fmt + tests (pull_request) Successful in 3m32s
b67fad969a
Add a one-click control in the sidebar footer that flips the active theme between light and dark without opening Settings.

`window.__lcToggleTheme` (base.html bootstrap) reads the resolved `data-theme`, flips dark<->light within the same contrast family (so a high-contrast user stays on high-contrast), applies it instantly via `__lcSetTheme`, and fire-and-forget persists it. The new `POST /settings/theme` endpoint saves only `users.theme`, returns 204, and stamps the `lc-theme` cookie so the next navigation has no flash-of-old-theme (the redirect-based appearance form already gets this for free). High-contrast and system stay on the Settings appearance picker.

An invalid theme value falls back to "system" instead of 500ing. en/es parity for the new `sidebar-toggle-theme` key.

#LC-292
#LC-293

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
longjacksonle deleted branch feat/lc-292-theme-quick-toggle 2026-06-14 20:51:42 +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
psa-systems/lets-chat!324
No description provided.