2022-04-23 00:43:42 +02:00
|
|
|
import { useMediaQuery, useStorage } from '@vueuse/core';
|
2022-04-04 01:52:59 +02:00
|
|
|
import { defineStore } from 'pinia';
|
2022-04-23 00:43:42 +02:00
|
|
|
import { watch, type Ref } from 'vue';
|
2022-04-04 01:52:59 +02:00
|
|
|
|
2022-04-04 17:27:34 +02:00
|
|
|
export const useStyleStore = defineStore('style', {
|
2022-04-18 08:36:22 +02:00
|
|
|
state: () => {
|
|
|
|
const isDarkTheme = useStorage('isDarkTheme', true) as Ref<boolean>;
|
|
|
|
const isSmallScreen = useMediaQuery('(max-width: 700px)');
|
2022-04-23 00:43:42 +02:00
|
|
|
const isMenuCollapsed = useStorage('isMenuCollapsed', isSmallScreen.value) as Ref<boolean>;
|
2022-04-18 08:36:22 +02:00
|
|
|
|
2022-04-23 00:43:42 +02:00
|
|
|
watch(isSmallScreen, (v) => (isMenuCollapsed.value = v));
|
2022-04-18 08:36:22 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
isDarkTheme,
|
|
|
|
isMenuCollapsed,
|
|
|
|
isSmallScreen,
|
|
|
|
};
|
|
|
|
},
|
2022-04-04 17:27:34 +02:00
|
|
|
});
|