Skip to content

Commit

Permalink
fix(theme): set defaultTheme variables on :root
Browse files Browse the repository at this point in the history
fixes #16751
fixes #16853
  • Loading branch information
KaelWD committed Mar 7, 2023
1 parent c8b3827 commit 32f35d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
19 changes: 9 additions & 10 deletions packages/vuetify/src/composables/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,12 @@ export function createTheme (options?: ThemeOptions): ThemeInstance & { install:
createCssClass(lines, ':root', ['color-scheme: dark'])
}

for (const [themeName, theme] of Object.entries(computedThemes.value)) {
const { variables, dark } = theme
createCssClass(lines, ':root', genCssVariables(current.value))

for (const [themeName, theme] of Object.entries(computedThemes.value)) {
createCssClass(lines, `.v-theme--${themeName}`, [
`color-scheme: ${dark ? 'dark' : 'normal'}`,
`color-scheme: ${theme.dark ? 'dark' : 'normal'}`,
...genCssVariables(theme),
...Object.keys(variables).map(key => {
const value = variables[key]
const color = typeof value === 'string' && value.startsWith('#') ? parseColor(value) : undefined
const rgb = color ? `${color.r}, ${color.g}, ${color.b}` : undefined

return `--v-${key}: ${rgb ?? value}`
}),
])
}

Expand Down Expand Up @@ -425,5 +418,11 @@ function genCssVariables (theme: InternalThemeDefinition) {
}
}

for (const [key, value] of Object.entries(theme.variables)) {
const color = typeof value === 'string' && value.startsWith('#') ? parseColor(value) : undefined
const rgb = color ? `${color.r}, ${color.g}, ${color.b}` : undefined
variables.push(`--v-${key}: ${rgb ?? value}`)
}

return variables
}
5 changes: 0 additions & 5 deletions packages/vuetify/src/styles/elements/_global.sass
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ html.overflow-y-hidden
overflow-y: hidden !important

:root
--v-theme-background: #fff
--v-theme-on-background: #000
--v-theme-surface: #fff
--v-theme-on-surface: #000
--v-theme-overlay-multiplier: 1
--v-scrollbar-offset: 0px

// iOS Safari hack to allow click events on body
Expand Down

0 comments on commit 32f35d7

Please sign in to comment.