import { acceptHMRUpdate, defineStore } from 'pinia' import { MAX_WIDTH_FOR_MOBILE_MODE } from '~/lib' export const useSidebarStore = defineStore('sidebarStore', () => { const { width } = useWindowSize() const isViewPortMobile = () => width.value < MAX_WIDTH_FOR_MOBILE_MODE const isLeftSidebarOpen = ref(!isViewPortMobile()) const isRightSidebarOpen = ref(true) const leftSidebarWidthPercent = ref(isViewPortMobile() ? 0 : 20) const leftSidebarWidth = computed(() => (width.value * leftSidebarWidthPercent.value) / 100) const leftSideBarSize = ref({ old: 20, current: leftSidebarWidthPercent.value, }) const rightSidebarSize = ref({ old: 17.5, current: 17.5, }) const leftSidebarState = ref< 'openStart' | 'openEnd' | 'hiddenStart' | 'hiddenEnd' | 'peekOpenStart' | 'peekOpenEnd' | 'peekCloseOpen' | 'peekCloseEnd' >(isLeftSidebarOpen.value ? 'openEnd' : 'hiddenEnd') const rightSidebarState = ref< 'openStart' | 'openEnd' | 'hiddenStart' | 'hiddenEnd' | 'peekOpenStart' | 'peekOpenEnd' | 'peekCloseOpen' | 'peekCloseEnd' >(isRightSidebarOpen.value ? 'openEnd' : 'hiddenEnd') return { isLeftSidebarOpen, isRightSidebarOpen, rightSidebarSize, leftSidebarWidthPercent, leftSideBarSize, leftSidebarState, rightSidebarState, leftSidebarWidth, } }) if (import.meta.hot) { import.meta.hot.accept(acceptHMRUpdate(useSidebarStore as any, import.meta.hot)) }