"use client"; import { useState } from "react"; import Link from "next/link"; import { Menu } from "lucide-react"; import { cn } from "@/lib/utils"; import { buttonVariants } from "@/components/ui/button"; import { Drawer, DrawerClose, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- export type MobileNavItem = { slug: string; label: string; href: string; type: string; /** For hierarchical books (SSR, DS) — parent chapter number */ parentChapter?: number | null; /** Whether this is a non-clickable parent heading */ isParent?: boolean; }; export type MobileNavGroup = { title?: string; items: MobileNavItem[]; }; // --------------------------------------------------------------------------- // Component // --------------------------------------------------------------------------- /** * Mobile sidebar drawer triggered by a menu button. * * Usage: Place this component alongside the prev/next buttons in any * book reader page. It renders a menu icon button (visible only on * mobile / below `lg` breakpoint) that opens a bottom drawer with * the full sidebar navigation. * * Supports two modes: * 1. **Flat groups** — pass `groups` for simple grouped lists * (Front Matter, Chapters, etc.) * 2. **Hierarchical** — pass `groups` where some items have * `isParent: true` to render parent headings with indented children */ export function MobileNav({ groups, currentSlug, bookTitle, }: { groups: MobileNavGroup[]; currentSlug: string; bookTitle?: string; }) { const [open, setOpen] = useState(false); return ( Contents {bookTitle ?? "Contents"} ); }