WIP jordan
This commit is contained in:
32
app/composables/useAppShellLayout.ts
Normal file
32
app/composables/useAppShellLayout.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
const STORAGE_KEY = 'policy-ui.sidebar.collapsed.v1'
|
||||
|
||||
export function useAppShellLayout() {
|
||||
const sidebarCollapsed = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
if (!import.meta.client) return
|
||||
try {
|
||||
sidebarCollapsed.value = localStorage.getItem(STORAGE_KEY) === '1'
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
})
|
||||
|
||||
watch(sidebarCollapsed, (c) => {
|
||||
if (!import.meta.client) return
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, c ? '1' : '0')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
})
|
||||
|
||||
function toggleSidebar() {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value
|
||||
}
|
||||
|
||||
return {
|
||||
sidebarCollapsed,
|
||||
toggleSidebar
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user