Now I remember the theme
This commit is contained in:
@@ -33,6 +33,30 @@ Persistence MUST be stored locally in the browser (e.g., localStorage).
|
||||
- **WHEN** the user selects `light` theme and reloads the page
|
||||
- **THEN** the `light` theme remains active
|
||||
|
||||
### Requirement: Theme persistence works across visits with fallback
|
||||
The site MUST persist the user's theme selection across visits so returning users see the last-selected theme.
|
||||
|
||||
The site MUST use client-side persistence and MUST support a fallback mechanism:
|
||||
- Primary: `localStorage`
|
||||
- Fallback: a client-side cookie
|
||||
|
||||
The effective theme selection order MUST be:
|
||||
1) Stored theme in `localStorage` (if available)
|
||||
2) Stored theme in a cookie (if localStorage is unavailable)
|
||||
3) Default selection using environment signals
|
||||
|
||||
#### Scenario: LocalStorage persists across a later visit
|
||||
- **WHEN** a user selects `light` theme and later returns to the site in the same browser
|
||||
- **THEN** the site initializes in `light` theme before first paint
|
||||
|
||||
#### Scenario: Cookie fallback is used when localStorage is unavailable
|
||||
- **WHEN** the browser environment blocks `localStorage` access and the user selects `dark` theme
|
||||
- **THEN** the theme is persisted using a client-side cookie and is restored on the next visit
|
||||
|
||||
#### Scenario: No persistence available falls back to defaults
|
||||
- **WHEN** both `localStorage` and cookie persistence are unavailable
|
||||
- **THEN** the site falls back to default theme selection using environment signals
|
||||
|
||||
### Requirement: Default theme selection
|
||||
If the user has not explicitly selected a theme, the site MUST choose a default theme using environment signals.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user