mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 15:15:02 -04:00
Remove theme store
This commit is contained in:
parent
7952709892
commit
cba734118a
3 changed files with 4 additions and 36 deletions
|
@ -1,17 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { BrandGithub, BrandTwitter, InfoCircle, Moon, Sun } from '@vicons/tabler';
|
import { BrandGithub, BrandTwitter, InfoCircle, Moon, Sun } from '@vicons/tabler';
|
||||||
import { useStyleStore } from '@/stores/style.store';
|
import { useStyleStore } from '@/stores/style.store';
|
||||||
import { useThemeStore } from '@/ui/theme/theme.store';
|
|
||||||
|
|
||||||
const styleStore = useStyleStore();
|
const styleStore = useStyleStore();
|
||||||
const { isDarkTheme } = toRefs(styleStore);
|
const { isDarkTheme } = toRefs(styleStore);
|
||||||
|
|
||||||
const themeStore = useThemeStore();
|
|
||||||
|
|
||||||
function toggleDarkTheme() {
|
|
||||||
styleStore.toggleDark();
|
|
||||||
themeStore.toggleTheme();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -57,7 +49,7 @@ function toggleDarkTheme() {
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
<n-tooltip trigger="hover">
|
<n-tooltip trigger="hover">
|
||||||
<template #trigger>
|
<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-if="isDarkTheme" size="25" :component="Sun" />
|
||||||
<n-icon v-else size="25" :component="Moon" />
|
<n-icon v-else size="25" :component="Moon" />
|
||||||
</c-button>
|
</c-button>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useThemeStore } from './theme.store';
|
import { useStyleStore } from '@/stores/style.store';
|
||||||
|
|
||||||
export { defineThemes };
|
export { defineThemes };
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ function defineThemes<Theme>(themes: { light: Theme; dark: Theme }) {
|
||||||
return {
|
return {
|
||||||
themes,
|
themes,
|
||||||
useTheme() {
|
useTheme() {
|
||||||
const themeStore = useThemeStore();
|
const styleStore = useStyleStore();
|
||||||
return computed(() => themes[themeStore.themeType]);
|
return computed(() => themes[styleStore.isDarkTheme ? 'dark' : 'light']);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
Loading…
Add table
Add a link
Reference in a new issue