aboutsummaryrefslogtreecommitdiff
path: root/src/stores
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-23 00:43:42 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-23 00:43:42 +0200
commitb22aa941f52009118d4d3cc98277cc4c402a4c77 (patch)
tree83b35a9b38c65ee560c7b7c7fee1308058a51210 /src/stores
parentb12cbe412407389186a58e4ceaa94f5b441c11ea (diff)
downloadit-tools-b22aa941f52009118d4d3cc98277cc4c402a4c77.tar.gz
it-tools-b22aa941f52009118d4d3cc98277cc4c402a4c77.tar.zst
it-tools-b22aa941f52009118d4d3cc98277cc4c402a4c77.zip
fix(sider): default collapsed value
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/style.store.ts16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/stores/style.store.ts b/src/stores/style.store.ts
index af1d1b9..bd6559a 100644
--- a/src/stores/style.store.ts
+++ b/src/stores/style.store.ts
@@ -1,22 +1,14 @@
-import { useMediaQuery, useStorage, whenever } from '@vueuse/core';
+import { useMediaQuery, useStorage } from '@vueuse/core';
import { defineStore } from 'pinia';
-import type { Ref } from 'vue';
+import { watch, type Ref } from 'vue';
export const useStyleStore = defineStore('style', {
state: () => {
const isDarkTheme = useStorage('isDarkTheme', true) as Ref<boolean>;
const isSmallScreen = useMediaQuery('(max-width: 700px)');
- const isMenuCollapsed = useStorage('isMenuCollapsed', !isSmallScreen.value) as Ref<boolean>;
+ const isMenuCollapsed = useStorage('isMenuCollapsed', isSmallScreen.value) as Ref<boolean>;
- whenever(
- () => !isSmallScreen.value,
- () => (isMenuCollapsed.value = false),
- );
-
- whenever(
- () => isSmallScreen.value,
- () => (isMenuCollapsed.value = true),
- );
+ watch(isSmallScreen, (v) => (isMenuCollapsed.value = v));
return {
isDarkTheme,