diff options
| author | Adam Malczewski <[email protected]> | 2026-06-01 09:45:36 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-01 09:45:36 +0900 |
| commit | 6c377fba7d516ea89ef2d906a40785a997299b0c (patch) | |
| tree | 32e4dde45fbb4f57680e92050798aa65f15e5a6f /packaging | |
| parent | 60999dc48d8c06a10ff8f5b3f6edb1d220fd85ca (diff) | |
| download | dispatch-6c377fba7d516ea89ef2d906a40785a997299b0c.tar.gz dispatch-6c377fba7d516ea89ef2d906a40785a997299b0c.zip | |
fix(theme): consolidate boot apply and Settings picker into shared module
Gemini review surfaced that App.svelte (onMount theme apply) and
SettingsPanel.svelte (theme <select>) hand-rolled their own defaults
and could disagree:
- App.svelte only set data-theme if localStorage had a value, so on a
fresh install daisyUI fell back to the first theme in app.css (light).
- SettingsPanel.svelte hardcoded a UI default of "dark".
Result: a first-time user saw a light app but a Settings panel that
claimed "dark" was selected. Picking *any* value in the dropdown was
the only way to reconcile reality with the UI.
This commit:
- Adds packages/frontend/src/lib/theme.ts as the single source of truth:
THEMES list, Theme type, THEME_STORAGE_KEY, DEFAULT_THEME, plus
loadStoredTheme() and applyTheme() that handle SSR / private-mode /
bad-value cases.
- Rewires App.svelte's onMount to call applyTheme(loadStoredTheme()),
so the boot apply always writes a known good theme to the DOM (even
on fresh installs), matching what Settings will show.
- Rewires SettingsPanel.svelte's picker to use the shared module,
dropping its duplicate THEMES const, duplicate storage key, duplicate
apply/persist logic, and the conflicting "dark" fallback.
- Adds 11 unit tests in tests/theme.test.ts covering the
default-fallback, known/unknown stored values, SecurityError-on-read,
SSR (no localStorage), DOM-attribute write, persistence round-trip,
and the "DOM still updates if storage write throws" contract.
The daisyUI plugin block in app.css still lists themes — that's a
CSS-time concern and can't be imported from TS, so it's kept in sync
by convention (noted in the new module's doc comment).
Diffstat (limited to 'packaging')
0 files changed, 0 insertions, 0 deletions
