Skip to content

use/themeRegistry ​

Overview ​

Stores base theme data and project overrides separately, with registration, override, and theme-merge APIs, plus a CSS-framework-independent class merger configured by setClassMerger.

Split out of useTheme.js so per-component *.theme.js modules can register their entries through a module that test specs do not mock. Specs mock the useTheme composable (@vueda/use/useTheme.js); they do not mock this registry, so a themed SFC's eager patchTheme(...) side effect resolves to the real function even when useTheme is mocked. useTheme.js re-exports setTheme / patchTheme / overrideTheme / clearThemeOverrides / setClassMerger / getTheme / mergeTheme so the public @vueda/use/useTheme.js import path is unchanged for existing callers.

Properties ​

defaultTheme ​

Reactive holder for the registered theme. setTheme / patchTheme reassign .value so any useTheme async computeds re-resolve when new entries arrive (e.g. a component-level loader resolved its chunk and called patchTheme with real data).

Type: ShallowRef

Source: client/lib/use/themeRegistry.js:28

Methods ​

  • clearThemeOverrides - Remove all project overrides without changing base entries or loaders.
  • combineThemeClasses - Combine class values, then apply the active theme's conflict rules.
  • getTheme - Get a cloned base theme snapshot.
  • mergeTheme - Custom merge function for merging theme objects, ensuring classes are combined.
  • overrideTheme - Merge project overrides above the base theme regardless of registration order.
  • patchTheme - Patch the default theme with a partial theme.
  • setClassMerger - Register the active theme's CSS conflict rules.
  • setTheme - Replace the base theme, including previous base patches.

Source ​

client/lib/use/themeRegistry.js:1