Remove theme store

This commit is contained in:
rmt/src 2023-06-17 23:01:39 +01:00
parent 7952709892
commit cba734118a
No known key found for this signature in database
GPG key ID: 6DD597637A8B880A
3 changed files with 4 additions and 36 deletions

View file

@ -1,17 +1,9 @@
<script setup lang="ts">
import { BrandGithub, BrandTwitter, InfoCircle, Moon, Sun } from '@vicons/tabler';
import { useStyleStore } from '@/stores/style.store';
import { useThemeStore } from '@/ui/theme/theme.store';
const styleStore = useStyleStore();
const { isDarkTheme } = toRefs(styleStore);
const themeStore = useThemeStore();
function toggleDarkTheme() {
styleStore.toggleDark();
themeStore.toggleTheme();
}
</script>
<template>
@ -57,7 +49,7 @@ function toggleDarkTheme() {
</n-tooltip>
<n-tooltip trigger="hover">
<template #trigger>
<c-button circle variant="text" aria-label="Toggle dark/light mode" @click="toggleDarkTheme">
<c-button circle variant="text" aria-label="Toggle dark/light mode" @click="() => styleStore.toggleDark()">
<n-icon v-if="isDarkTheme" size="25" :component="Sun" />
<n-icon v-else size="25" :component="Moon" />
</c-button>

View file

@ -1,4 +1,4 @@
import { useThemeStore } from './theme.store';
import { useStyleStore } from '@/stores/style.store';
export { defineThemes };
@ -6,8 +6,8 @@ function defineThemes<Theme>(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']);
},
};
}

View file

@ -1,24 +0,0 @@
import { defineStore } from 'pinia';
import { useStyleStore } from '@/stores/style.store';
export const useThemeStore = defineStore('ui-theme', {
state: () => {
const styleStore = useStyleStore();
return {
themeType: styleStore.isDarkTheme ? 'dark' : 'light',
};
},
getters: {
isDarkTheme(): boolean {
return this.themeType === 'dark';
},
isLightTheme(): boolean {
return this.themeType === 'light';
},
},
actions: {
toggleTheme() {
this.themeType = this.isDarkTheme ? 'light' : 'dark';
},
},
});