diff --git a/src/components/NavbarButtons.vue b/src/components/NavbarButtons.vue
index 81661d9f..5b1a3a4e 100644
--- a/src/components/NavbarButtons.vue
+++ b/src/components/NavbarButtons.vue
@@ -1,18 +1,9 @@
@@ -58,7 +49,7 @@ function toggleDarkTheme() {
-
+ styleStore.toggleDark()">
diff --git a/src/stores/style.store.ts b/src/stores/style.store.ts
index d70bd768..8342a880 100644
--- a/src/stores/style.store.ts
+++ b/src/stores/style.store.ts
@@ -1,10 +1,11 @@
-import { useMediaQuery, useStorage } from '@vueuse/core';
+import { useDark, useMediaQuery, useStorage, useToggle } from '@vueuse/core';
import { defineStore } from 'pinia';
import { type Ref, watch } from 'vue';
export const useStyleStore = defineStore('style', {
state: () => {
- const isDarkTheme = useStorage('isDarkTheme', true) as Ref;
+ const isDarkTheme = useDark();
+ const toggleDark = useToggle(isDarkTheme);
const isSmallScreen = useMediaQuery('(max-width: 700px)');
const isMenuCollapsed = useStorage('isMenuCollapsed', isSmallScreen.value) as Ref;
@@ -12,6 +13,7 @@ export const useStyleStore = defineStore('style', {
return {
isDarkTheme,
+ toggleDark,
isMenuCollapsed,
isSmallScreen,
};
diff --git a/src/ui/theme/theme.models.ts b/src/ui/theme/theme.models.ts
index 850afe95..5ab78d79 100644
--- a/src/ui/theme/theme.models.ts
+++ b/src/ui/theme/theme.models.ts
@@ -1,4 +1,4 @@
-import { useThemeStore } from './theme.store';
+import { useStyleStore } from '@/stores/style.store';
export { defineThemes };
@@ -6,8 +6,8 @@ function defineThemes(themes: { light: Theme; dark: Theme }) {
return {
themes,
useTheme() {
- const themeStore = useThemeStore();
- return computed(() => themes[themeStore.themeType]);
+ const styleStore = useStyleStore();
+ return computed(() => themes[styleStore.isDarkTheme ? 'dark' : 'light']);
},
};
}
diff --git a/src/ui/theme/theme.store.ts b/src/ui/theme/theme.store.ts
deleted file mode 100644
index e2457fca..00000000
--- a/src/ui/theme/theme.store.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { defineStore } from 'pinia';
-
-export const useThemeStore = defineStore('ui-theme', {
- state: () => ({
- themeType: useStorage<'dark' | 'light'>('ui-store:theme-type', 'dark') as Ref<'dark' | 'light'>,
- }),
- getters: {
- isDarkTheme(): boolean {
- return this.themeType === 'dark';
- },
- isLightTheme(): boolean {
- return this.themeType === 'light';
- },
- },
- actions: {
- toggleTheme() {
- this.themeType = this.isDarkTheme ? 'light' : 'dark';
- },
- },
-});