From 9a07a0b42cfe4da74ee31fb313a84d667d9b4c99 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 15 Mar 2024 10:22:40 +0000 Subject: [PATCH] Cosmetics --- components/lib/config/PrimeVue.js | 8 +------- components/lib/themes/utils/themeUtils.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/components/lib/config/PrimeVue.js b/components/lib/config/PrimeVue.js index ffdf46e7d..09e82430b 100644 --- a/components/lib/config/PrimeVue.js +++ b/components/lib/config/PrimeVue.js @@ -141,13 +141,7 @@ export const defaultOptions = { preset: Aura, options: { prefix: 'p', - colorScheme: { - dark: { - class: 'p-dark', - rule: `.p-dark { [CSS] }` - //default: false - } - }, + colorScheme: 'auto', layer: false /*colorScheme: { // mode: 'light' | 'dark' | 'auto' | object // default: auto diff --git a/components/lib/themes/utils/themeUtils.js b/components/lib/themes/utils/themeUtils.js index f82978dba..6d338700c 100644 --- a/components/lib/themes/utils/themeUtils.js +++ b/components/lib/themes/utils/themeUtils.js @@ -84,21 +84,17 @@ export default { return options; }, applyColorScheme(options = {}, currentColorScheme, defaults) { - if (options.colorScheme) { - const colorSchemeOption = this.getColorSchemeOption(options.colorScheme, defaults); - const isClient = SharedUtils.dom.isClient(); - const isAuto = !colorSchemeOption.light?.default && !colorSchemeOption.dark?.default; - const isDark = isAuto && isClient ? window.matchMedia('(prefers-color-scheme: dark)').matches : colorSchemeOption.dark?.default; - const defaultDocument = isClient ? window.document : undefined; + const colorSchemeOption = this.getColorSchemeOption(options.colorScheme, defaults); + const isClient = SharedUtils.dom.isClient(); + const isAuto = !colorSchemeOption.light?.default && !colorSchemeOption.dark?.default; + const isDark = isAuto && isClient ? window.matchMedia('(prefers-color-scheme: dark)').matches : colorSchemeOption.dark?.default; + const defaultDocument = isClient ? window.document : undefined; - if (isDark && defaultDocument) { - SharedUtils.dom.addClass(defaultDocument.documentElement, colorSchemeOption.dark?.class); - } - - return isDark ? 'dark' : 'light'; + if (isDark && defaultDocument) { + SharedUtils.dom.addClass(defaultDocument.documentElement, colorSchemeOption.dark?.class); } - return currentColorScheme; + return isDark ? 'dark' : 'light'; }, toggleColorScheme(options = {}, currentColorScheme, defaults) { const newColorScheme = currentColorScheme === 'dark' ? 'light' : 'dark';