38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
// Pinia replacement for the parts of legacy henza_admin/src/store/state.js +
|
|||
|
|
// mutations.js that the app shell actually uses: window width, scroll position,
|
||
|
|
// and the active theme. The Vuexy customizer state (sidebar width, theme tour,
|
||
|
|
// footer type, ...) is carried in themeConfig.ts instead, as in legacy.
|
||
|
|
import { defineStore } from 'pinia';
|
||
|
|
import themeConfig, { type ThemeMode } from '../themeConfig';
|
||
|
|
|
||
|
|
export const useLayoutStore = defineStore('layout', {
|
||
|
|
state: () => ({
|
||
|
|
windowWidth: typeof window !== 'undefined' ? window.innerWidth : 0,
|
||
|
|
scrollY: 0,
|
||
|
|
theme: themeConfig.theme as ThemeMode,
|
||
|
|
// legacy state.js: sidebar visibility for the vertical nav menu
|
||
|
|
isSidebarActive: true,
|
||
|
|
sidebarCollapsed: themeConfig.sidebarCollapsed,
|
||
|
|
}),
|
||
|
|
getters: {
|
||
|
|
// legacy used breakpoints of 1200 (theme tour) and 992 (nav menu collapse)
|
||
|
|
isSmallScreen: (s) => s.windowWidth < 992,
|
||
|
|
},
|
||
|
|
actions: {
|
||
|
|
// legacy mutation: UPDATE_WINDOW_WIDTH
|
||
|
|
updateWindowWidth(width: number) {
|
||
|
|
this.windowWidth = width;
|
||
|
|
},
|
||
|
|
// legacy mutation: UPDATE_WINDOW_SCROLL_Y
|
||
|
|
updateWindowScrollY(y: number) {
|
||
|
|
this.scrollY = y;
|
||
|
|
},
|
||
|
|
toggleSidebar(value?: boolean) {
|
||
|
|
this.isSidebarActive = value ?? !this.isSidebarActive;
|
||
|
|
},
|
||
|
|
setSidebarCollapsed(value: boolean) {
|
||
|
|
this.sidebarCollapsed = value;
|
||
|
|
},
|
||
|
|
},
|
||
|
|
});
|