Files
writer-work-flow/apps/web/components/NavDrawer.tsx

50 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useRef, useState } from "react";
import { Menu } from "lucide-react";
import { Button } from "@/components/ui/Button";
import type { ActiveNav } from "@/lib/nav/items";
import { Drawer } from "./Drawer";
import { NavItems } from "./NavItems";
interface NavDrawerProps {
projectId?: string;
activeNav?: ActiveNav;
}
// 移动端导航:汉堡按钮 + 左侧抽屉(仅 <lg桌面用 LeftNav 静态侧栏。UX §5.1。
export function NavDrawer({ projectId, activeNav }: NavDrawerProps) {
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
return (
<>
<Button
ref={triggerRef}
onClick={() => setOpen(true)}
aria-label="打开导航"
aria-expanded={open}
variant="ghost"
size="icon"
className="-ml-2 lg:hidden"
>
<Menu className="h-5 w-5" aria-hidden="true" />
</Button>
<Drawer
open={open}
onClose={() => setOpen(false)}
side="left"
label="主导航"
triggerRef={triggerRef}
>
<NavItems
projectId={projectId}
activeNav={activeNav}
onNavigate={() => setOpen(false)}
/>
</Drawer>
</>
);
}