Cosmetics

pull/5507/head
mertsincan 2024-03-15 10:22:40 +00:00
parent 9b0f1ac98a
commit 9a07a0b42c
2 changed files with 9 additions and 19 deletions

View File

@ -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

View File

@ -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';