Skip to content

Commit a14c763

Browse files
committed
fix(theme): re-merge default variables when themes is set
1 parent 8a619ee commit a14c763

File tree

1 file changed

+12
-17
lines changed
  • packages/vuetify/src/composables

1 file changed

+12
-17
lines changed

packages/vuetify/src/composables/theme.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,7 @@ function parseThemeOptions (options: ThemeOptions = genDefaults()): InternalThem
222222

223223
if (!options) return { ...defaults, isDisabled: true } as any
224224

225-
const themes: Record<string, InternalThemeDefinition> = {}
226-
for (const [key, theme] of Object.entries(options.themes ?? {})) {
227-
const defaultTheme = theme.dark || key === 'dark'
228-
? defaults.themes?.dark
229-
: defaults.themes?.light
230-
themes[key] = mergeDeep(defaultTheme, theme) as InternalThemeDefinition
231-
}
232-
233-
return mergeDeep(
234-
defaults,
235-
{ ...options, themes },
236-
) as InternalThemeOptions
225+
return mergeDeep(defaults, options) as InternalThemeOptions
237226
}
238227

239228
function createCssClass (lines: string[], selector: string, content: string[], scope?: string) {
@@ -365,17 +354,23 @@ export function createTheme (options?: ThemeOptions): ThemeInstance & { install:
365354

366355
const computedThemes = computed(() => {
367356
const acc: Record<string, InternalThemeDefinition> = {}
368-
for (const [name, original] of Object.entries(themes.value)) {
357+
for (const [name, original] of Object.entries(parsedOptions.themes)) {
358+
const defaultTheme = original.dark || name === 'dark'
359+
? parsedOptions.themes.dark
360+
: parsedOptions.themes.light
361+
362+
const merged = mergeDeep(defaultTheme, original) as InternalThemeDefinition
363+
369364
const colors = {
370-
...original.colors,
371-
...genVariations(original.colors, parsedOptions.variations),
365+
...merged.colors,
366+
...genVariations(merged.colors, parsedOptions.variations),
372367
}
373368

374369
acc[name] = {
375-
...original,
370+
...merged,
376371
colors: {
377372
...colors,
378-
...genOnColors(colors, original.variables),
373+
...genOnColors(colors, merged.variables),
379374
},
380375
}
381376
}

0 commit comments

Comments
 (0)