Fix light/dark mode preference not persisting on reload #17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The theme toggle (light/dark mode) works during a session but resets to the default on every page reload, forcing users to re-apply their preference each time.
Goals
Implementation Spec for Issue #17
Objective
The theme toggle works in-session but resets on every reload because the selection is never written to storage and the page always boots with
data-bs-theme="dark"hard-coded in the HTML. This spec describes the minimal, flash-free fix.Requirements
"light"or"dark") tolocalStorageunder the keyheroSlidesThemeheroSlidesThemeand apply it to<html data-bs-theme>before the browser paints (no flash)Files to Modify
crates/hero_slides_ui/templates/base.html<script>in<head>that reads localStorage and setsdata-bs-themeimmediately; remove hard-codeddata-bs-theme="dark"from<html>tagcrates/hero_slides_ui/static/js/dashboard.jslocalStorage.setItemon toggle; add icon sync on initial loadImplementation Plan
Step 1: Remove hard-coded theme from
<html>tag inbase.html<html lang="en" data-bs-theme="dark">to<html lang="en">Dependencies: none
Step 2: Add blocking inline script to
<head>inbase.html<head>, before any<link>or<meta>localStorage.getItem('heroSlidesTheme')and setsdata-bs-theme; falls back to'dark'Dependencies: Step 1
Step 3: Persist theme to localStorage on toggle in
dashboard.jslocalStorage.setItem('heroSlidesTheme', next)inside the existing toggle click handlerDependencies: none
Step 4: Sync toggle icon to restored theme on load in
dashboard.jsDependencies: none
Acceptance Criteria
hero:themepostMessage bridgePull request opened: #19