From 22e21166bff6b154a021f8ec074562c963cb35bf Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Tue, 6 Feb 2024 09:16:39 +0300 Subject: [PATCH] Remove stateful dark toggle until new theming api --- app.vue | 7 ------- error.vue | 7 ------- layouts/default.vue | 3 --- pages/index.vue | 10 ---------- plugins/app-state.js | 3 +-- 5 files changed, 1 insertion(+), 29 deletions(-) diff --git a/app.vue b/app.vue index 72a3b7717..e1a89e51c 100644 --- a/app.vue +++ b/app.vue @@ -34,13 +34,6 @@ export default { }); }, mounted() { - const preferredColorScheme = localStorage.getItem(this.$appState.colorSchemeKey); - const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches; - - if ((preferredColorScheme === null && prefersDarkColorScheme) || preferredColorScheme === 'dark') { - this.applyTheme({ theme: 'aura-dark-green', dark: true }); - } - EventBus.on('theme-change', this.themeChangeListener); }, beforeUnmount() { diff --git a/error.vue b/error.vue index 77ff64319..84271f477 100644 --- a/error.vue +++ b/error.vue @@ -39,13 +39,6 @@ export default { }); }, mounted() { - const preferredColorScheme = localStorage.getItem(this.$appState.colorSchemeKey); - const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches; - - if ((preferredColorScheme === null && prefersDarkColorScheme) || preferredColorScheme === 'dark') { - this.applyTheme({ theme: 'aura-dark-green', dark: true }); - } - EventBus.on('theme-change', this.themeChangeListener); }, beforeUnmount() { diff --git a/layouts/default.vue b/layouts/default.vue index 2d4f483c3..72dec2ca7 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -104,12 +104,9 @@ export default { if (this.$appState.darkTheme) { newTheme = currentTheme.replace('dark', 'light'); - localStorage.setItem(this.$appState.colorSchemeKey, 'light'); } else { if (currentTheme.includes('light')) newTheme = currentTheme.replace('light', 'dark'); else newTheme = 'aura-dark-green'; //fallback - - localStorage.setItem(this.$appState.colorSchemeKey, 'dark'); } EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme }); diff --git a/pages/index.vue b/pages/index.vue index 41546b83a..38163bd28 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -52,22 +52,12 @@ export default { expire.setTime(today.getTime() + 3600000 * 24 * 7); document.cookie = 'primeaffiliateid=' + afId + ';expires=' + expire.toUTCString() + ';path=/; domain:primefaces.org'; } - - const preferredColorScheme = localStorage.getItem(this.$appState.colorSchemeKey); - const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches; - - if ((preferredColorScheme === null && prefersDarkColorScheme) || preferredColorScheme === 'dark') { - this.replaceTableTheme('aura-dark-green'); - } else { - this.replaceTableTheme('aura-light-green'); - } }, methods: { onDarkModeToggle() { const newTheme = this.$appState.darkTheme ? 'aura-light-green' : 'aura-dark-green'; const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark'); - localStorage.setItem(this.$appState.colorSchemeKey, this.$appState.darkTheme ? 'light' : 'dark'); EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme }); this.replaceTableTheme(newTableTheme); }, diff --git a/plugins/app-state.js b/plugins/app-state.js index 9bc2c53c5..ef7998633 100644 --- a/plugins/app-state.js +++ b/plugins/app-state.js @@ -8,8 +8,7 @@ const $appState = { newsActive: false, announcement: null, ripple: false, - storageKey: 'primevue', - colorSchemeKey: 'primevue-color-scheme' + storageKey: 'primevue' }); } };