mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor
This commit is contained in:
parent
6730af3d20
commit
23fbb68f52
3 changed files with 37 additions and 48 deletions
|
@ -91,32 +91,15 @@ export default {
|
|||
this._loadGlobalStyles();
|
||||
this._hook('onBeforeMount');
|
||||
|
||||
// @todo
|
||||
// apply colorScheme settings
|
||||
const { colorScheme } = this.$globalThemeOptions || {};
|
||||
|
||||
let colorSchemeOption = {
|
||||
light: {
|
||||
class: '',
|
||||
default: false
|
||||
},
|
||||
dark: {
|
||||
class: 'p-dark',
|
||||
default: false
|
||||
}
|
||||
};
|
||||
|
||||
if (colorScheme) {
|
||||
if (ObjectUtils.isObject(colorScheme)) {
|
||||
colorSchemeOption.light = { ...colorSchemeOption.light, ...colorScheme.light };
|
||||
colorSchemeOption.dark = { ...colorSchemeOption.dark, ...colorScheme.dark };
|
||||
} else {
|
||||
colorSchemeOption.light = { ...colorSchemeOption.light, default: colorScheme !== 'auto' && colorScheme !== 'dark' };
|
||||
colorSchemeOption.dark = { ...colorSchemeOption.dark, default: colorScheme === 'dark' };
|
||||
}
|
||||
|
||||
const colorSchemeOption = BaseStyle.getColorSchemeOption(colorScheme);
|
||||
const isClient = DomHandler.isClient();
|
||||
const isAuto = !colorSchemeOption.light?.default && !colorSchemeOption.dark?.default;
|
||||
const isDark = isAuto ? window.matchMedia('(prefers-color-scheme: dark)') : colorSchemeOption.dark?.default;
|
||||
const defaultDocument = DomHandler.isClient() ? window.document : undefined;
|
||||
const isDark = isAuto && isClient ? window.matchMedia('(prefers-color-scheme: dark)') : colorSchemeOption.dark?.default;
|
||||
const defaultDocument = isClient ? window.document : undefined;
|
||||
|
||||
Theme.setColorMode(isDark ? 'dark' : 'light');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue