feat(frontend): dark-theme token overrides via data-theme with explicit-choice persistence - #1452
Open
okonkwofreeman001 wants to merge 2 commits into
Open
feat(frontend): dark-theme token overrides via data-theme with explicit-choice persistence#1452okonkwofreeman001 wants to merge 2 commits into
okonkwofreeman001 wants to merge 2 commits into
Conversation
…it-choice persistence Move the dark semantic palette into a [data-theme="dark"] override block layered on the base tokens, and switch the theme mechanism from dark-mode/light-mode classes to a data-theme attribute that is only pinned for explicit user choices. With no stored preference the app follows prefers-color-scheme live via CSS and a matchMedia listener, and an explicit stored choice can never be overridden by an OS-level theme change. Also fixes a latent bug where system-following dark was misread as an explicit choice, which disabled live OS-following. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
…ersistence feat(frontend): dark-theme token overrides via data-theme with explicit-choice persistence
|
@okonkwofreeman001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1324
Closes #1325
Closes #1326
Closes #1327
Description
Layers the dark theme on top of the base design tokens and reworks theme persistence so the app can tell "the user explicitly chose a theme" apart from "following the OS default".
Dark-theme overrides. The dark semantic palette now lives in a
[data-theme="dark"]block intokens.cssthat declares an override for every semantic token from the base:rootset (brand accents, surface/background/border/foreground families,--primary,--accent,--destructive,--success,--ring, all shadows, andcolor-scheme). Explicit light moved to[data-theme="light"].Persistence model. The theme mechanism switched from
dark-mode/light-modeclasses to adata-themeattribute that is only pinned when a preference is stored inlocalStorage:data-theme="dark"|"light"is set before first paint (blocking init script) and on every toggle.prefers-color-schemeis followed live via the@media (prefers-color-scheme: light) { :root:not([data-theme]) }rule plus amatchMedialistener — OS changes apply without a page reload.:not([data-theme])) and no OS-change listener is registered while a preference is stored.Latent bug fixed. Previously, system-following dark applied the
dark-modeclass and was misread by the hook as an explicit choice (hasStoredPreference: true), which disabled the live OS-following listener. Attribute-absence now unambiguously means "following the system," so OS changes keep being tracked.Type of Change
Testing Done
useDarkModeunit suite rewritten for the attribute model — 18/18 pass, including new coverage for:jestrun: 5 failing suites (30 tests) are pre-existing and unrelated — verified identical with the changes stashed (LandingPage.accessibility,LandingPage.keyboard,Statistics,useAsync,useReferral).tsc --noEmit: only pre-existing errors in e2e specs andfrontend-mock.test.ts; none in the changed files.Bundle Size
Not measured — the change adds no dependencies and only ~50 lines of CSS plus small TS edits (runtime code is similar in size to what it replaces).
Checklist
docs/architecture.mdRelated Issues
Follows on from the base-token work (task #11 in the design-token series). No dedicated issue number was provided for this task, so no
Closesreference is included.