mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-01 03:09:34 +00:00
Initial Commit
This commit is contained in:
commit
f3e2f01bd7
150 changed files with 13612 additions and 0 deletions
49
app/(platform)/(dashboard)/_components/mobile-sidebar.tsx
Normal file
49
app/(platform)/(dashboard)/_components/mobile-sidebar.tsx
Normal file
|
@ -0,0 +1,49 @@
|
|||
"use client";
|
||||
|
||||
import { Menu } from "lucide-react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useMobileSidebar } from "@/hooks/use-mobile-sidebar";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Sheet, SheetContent } from "@/components/ui/sheet";
|
||||
import { Sidebar } from "./sidebar";
|
||||
|
||||
export const MobileSidebar = () => {
|
||||
const pathname = usePathname();
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
|
||||
const onOpen = useMobileSidebar((state) => state.onOpen);
|
||||
const onClose = useMobileSidebar((state) => state.onClose);
|
||||
const isOpen = useMobileSidebar((state) => state.isOpen);
|
||||
|
||||
useEffect(() => {
|
||||
setIsMounted(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
onClose();
|
||||
}, [pathname, onClose]);
|
||||
|
||||
if (!isMounted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
onClick={onOpen}
|
||||
className="block md:hidden mr-2"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
>
|
||||
<Menu className="h-4 w-4" />
|
||||
</Button>
|
||||
<Sheet open={isOpen} onOpenChange={onClose}>
|
||||
<SheetContent side="left" className="p-2 pt-10">
|
||||
<Sidebar storageKey="t-sidebar-mobile-state" />
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
</>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue