init: чистый старт Laravel + Vuexy
This commit is contained in:
29
resources/ts/@core/composable/useResponsiveSidebar.ts
Normal file
29
resources/ts/@core/composable/useResponsiveSidebar.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { Ref } from 'vue'
|
||||
import { useDisplay } from 'vuetify'
|
||||
|
||||
export const useResponsiveLeftSidebar = (mobileBreakpoint: Ref<boolean> | undefined = undefined) => {
|
||||
const { mdAndDown, name: currentBreakpoint } = useDisplay()
|
||||
|
||||
const _mobileBreakpoint = mobileBreakpoint || mdAndDown
|
||||
|
||||
const isLeftSidebarOpen = ref(true)
|
||||
|
||||
const setInitialValue = () => {
|
||||
isLeftSidebarOpen.value = !_mobileBreakpoint.value
|
||||
}
|
||||
|
||||
// Set the initial value of sidebar
|
||||
setInitialValue()
|
||||
|
||||
watch(
|
||||
currentBreakpoint,
|
||||
() => {
|
||||
// Reset left sidebar
|
||||
isLeftSidebarOpen.value = !_mobileBreakpoint.value
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
isLeftSidebarOpen,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user