3import { MenuIcon } from 'lucide-react';
11import { Drawer as VaulHeader } from 'vaul';
13interface DrawerContextProps {
15 setOpen: (open: boolean) => void;
18const DrawerContext = createContext<DrawerContextProps | undefined>(undefined);
20const useSidebarDrawer = () => {
21 const context = useContext(DrawerContext);
23 throw new Error('useDrawer must be used within a DrawerProvider');
28interface DrawerSidebarProps {
31 setOpen?: (open: boolean) => void;
35export function HeaderDrawer({
38 setOpen: controlledSetOpen,
41 const [internalOpen, setInternalOpen] = useState(false);
42 const open = controlledOpen !== undefined ? controlledOpen : internalOpen;
44 controlledSetOpen !== undefined ? controlledSetOpen : setInternalOpen;
46 const [isDesktop, setIsDesktop] = useState(false);
49 const mediaQuery = window.matchMedia('(min-width: 768px)');
50 const handleMediaChange = (event: MediaQueryListEvent) => {
51 setIsDesktop(event.matches);
54 setIsDesktop(mediaQuery.matches);
55 mediaQuery.addEventListener('change', handleMediaChange);
58 mediaQuery.removeEventListener('change', handleMediaChange);
64 <DrawerContext.Provider value={{ open, setOpen }}>
70 dismissible={isDesktop ? false : true}
73 <VaulHeader.Trigger asChild>{drawerBtn()}</VaulHeader.Trigger>
76 <VaulHeader.Overlay className='fixed inset-0 dark:bg-black/40 bg-white/50 backdrop-blur-sm z-50 ' />
77 <VaulHeader.Content className='dark:bg-gray-900 bg-white border-b z-50 w-full h-fit py-3 fixed top-0 left-0'>
83 </DrawerContext.Provider>
87export function DrawerContent({ children }: { children: ReactNode }) {