feat(lib-vuetify): system theme option and theme-switcher improvements#34
Open
BatLeDev wants to merge 3 commits into
Open
feat(lib-vuetify): system theme option and theme-switcher improvements#34BatLeDev wants to merge 3 commits into
BatLeDev wants to merge 3 commits into
Conversation
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.
…er host-provided theme offers
87060e8 to
67c0688
Compare
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.
Add a
systemtheme option to the theme-switcher and let host apps supply their own theme offers.What changed:
systemtheme that follows the OSprefers-color-scheme/forced-colors, and treat an absentthemecookie as implicitsystem.resolveTheme(replacing the privategetDefaultTheme) plus theTheme/AppliedTheme/ThemeOffers/FullSiteInfotypes, so consumers can resolve a stored preference to a concrete theme. Vuetify'sdefaultThemenow uses the resolved name (its built-in'system'would otherwise bypass custom themes).system.themeprop to the switcher so hosts that don't expose config viasession.fullSite(e.g. the Nuxt portal) can drive which options are shown.window.matchMediaaccess for SSR; capitalize the i18n labels.Why: improve the theme-switcher so users can defer to their OS preference, and so hosts with their own theme config can reuse the component.
Regression risks:
session.theme.valuenow defaults to'system'(wasnull) and is no longer mutated to a concrete theme on site load. Consumers reading it to know the applied theme, or checking== nullfor "no choice", must useresolveTheme(session.theme.value, fullSite)instead.FullSiteInfo.theme.dark/hc/hcDarkare now optional (interface is now exported); downstream code assigning them to a strictbooleanmay need a?? false.vuetifySessionOptionsforcesdefaultTheme: 'default'whenfullSiteis unset, instead of echoingsession.theme.value— low impact, but a behavior change.