Skip to content

feat(theme): add ThemeSwitcher component and useTheme singleton#762

Open
aerodeval wants to merge 7 commits into
frappe:mainfrom
aerodeval:feat-themeswitcher
Open

feat(theme): add ThemeSwitcher component and useTheme singleton#762
aerodeval wants to merge 7 commits into
frappe:mainfrom
aerodeval:feat-themeswitcher

Conversation

@aerodeval

@aerodeval aerodeval commented Jun 7, 2026

Copy link
Copy Markdown
Member

ThemeSwitcher Component

Adds a ThemeSwitcher component for choosing between light, dark, and system appearance, and refactors useTheme into a shared singleton so every theme control stays in sync.

image

What's Included

  • ThemeSwitcher — renders the three options as live preview cards (built on reka-ui RadioGroup). Selecting one drives the global <html data-theme>, so a bare <ThemeSwitcher /> switches the whole app with no wiring.
  • useTheme refactor — hoisted to a module-level singleton with a single app-lifetime system-preference listener and SSR guards. Same return shape as before (no breakage). Now the switcher, a sidebar toggle, etc. all read/write one source of truth.
  • PropsmodelValue (v-model), label, description, logo (image URL or Component), name, themeLabels (for translation).
  • Cypress tests, docs page, auto-generated API reference, and three stories (Default, Branded, Toggle).

Notes

  • Preview cards intentionally use literal light/dark colors instead of semantic tokens — each card must always depict its own theme regardless of the app's current theme. Chrome and labels use semantic tokens as usual.
  • Docs and sidebar entry are auto-discovered (component has both stories/ and ThemeSwitcher.md), so no manual nav wiring needed.

Testing

  • vue-tsc — no new type errors.
  • Cypress component tests cover rendering, default/custom labels, controlled selection, aria-checked, and driving <html data-theme>.

Coverage: 57.12% (+0.23% vs main)

@aerodeval aerodeval marked this pull request as draft June 7, 2026 15:25
@aerodeval aerodeval requested a review from shariquerik June 9, 2026 11:56
@aerodeval aerodeval marked this pull request as ready for review June 9, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant