Skip to content

feat(lib-vuetify): system theme option and theme-switcher improvements#34

Draft
BatLeDev wants to merge 3 commits into
mainfrom
feat-theme-switcher
Draft

feat(lib-vuetify): system theme option and theme-switcher improvements#34
BatLeDev wants to merge 3 commits into
mainfrom
feat-theme-switcher

Conversation

@BatLeDev
Copy link
Copy Markdown
Member

Summary

  • feat(lib-vue, lib-vuetify): 'system' theme option — the OS theme preference (prefers-color-scheme, forced-colors) was previously consulted only on the very first visit, then locked into the theme cookie and never re-evaluated. Mobile devices that toggle light/dark over the day were stuck on the initial choice. 'system' is now an explicit value of the Theme union, resolved to the actual applied theme via a new resolveTheme() helper. A matchMedia listener re-applies the theme reactively (no reload) while the user is on 'system'. The theme-switcher exposes a new "Système" / "System" radio option. Verified that simple-directory does not read the theme cookie server-side and reuses lib-vuetify's theme-switcher directly, so this new cookie value is transparently handled there too.
  • feat(lib-vue, lib-vuetify): expose resolveTheme and let hosts provide their own theme offersresolveTheme, AppliedTheme, Theme, FullSiteInfo and a new ThemeOffers loose shape are now exported from @data-fair/lib-vue/session.js. The theme-switcher accepts an optional theme prop so hosts whose configuration does not live in session.fullSite (e.g. the public Nuxt portal, where the theme is read from portalConfig) can drive which radios are shown without having to fork the component. Falls back to session.fullSite.value?.theme — historical behaviour preserved for existing data-fair UIs.
  • fix(lib-vuetify): capitalize theme-switcher i18n labels — the four theme-switcher options (Default / Par défaut, Dark / Sombre, High contrast / Contraste élevé, Dark and high contrast / Sombre et contraste élevé) now start with a capital letter in both locales.

BatLeDev added 3 commits May 22, 2026 14:40
Theme switcher options (default, dark, high contrast, dark and high contrast)
now start with a capital letter in both locales.
Previously the OS theme preference (prefers-color-scheme, forced-colors) was
only consulted once on the very first visit; after that the resolved value was
locked in the `theme` cookie and never re-evaluated. On mobile devices that
toggle light/dark over the day, the chosen theme could not follow the OS.

- Add `'system'` to the `Theme` union and store it explicitly in the cookie.
- New `resolveTheme()` helper derives the effective theme via `getDefaultTheme`
  when the user is on 'system' (or when the cookie is absent, which is now
  treated as an implicit 'system' choice).
- Listen to `prefers-color-scheme` and `forced-colors` matchMedia changes and
  re-apply the theme reactively while the user is on 'system' — no reload.
- Expose a 'system' radio option in the theme-switcher (i18n: Système / System).

simple-directory does not read the theme cookie server-side (verified across
its api/ and ui/ sources) and reuses lib-vuetify's theme-switcher directly, so
the new cookie value is transparently handled there too.
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