"use client" import { SideNav } from "@/components/sidenav" import { useRoute } from "@/lib/use-route" import { useScrollIntoView } from "@/lib/use-scroll-into-view" import { Box, BoxProps, IconButton, Portal, Stack, Text, chakra, } from "@chakra-ui/react" import { BreadcrumbRoot } from "compositions/ui/breadcrumb" import { DrawerBackdrop, DrawerBody, DrawerCloseTrigger, DrawerContent, DrawerRoot, DrawerTrigger, } from "compositions/ui/drawer" import { usePathname } from "next/navigation" import { useEffect, useRef, useState } from "react" import { AiOutlineClose, AiOutlineMenu, AiOutlineRight } from "react-icons/ai" export const SidebarStart = (props: BoxProps) => { const containerRef = useRef(null) const route = useRoute() useScrollIntoView(containerRef, '[aria-current="page"]', "center") return ( {route .getSidebarNavItems() ?.map((group) => ( ))} ) } export const SidebarEnd = (props: BoxProps) => { const { children } = props return ( {children} ) } const MobileMenuButton = chakra("button", { base: { display: "flex", px: "4", py: "2", gap: "2", w: "full", hideFrom: "md", fontSize: "md", alignItems: "center", color: "fg", position: "sticky", zIndex: "10", top: "var(--header-height)", borderBottom: "1px solid", borderColor: "border.subtle", cursor: "pointer", bg: "bg", }, }) export const MobileMenuBreadcrumbs = () => { const route = useRoute() const crumbs = route .getSidebarNavItems() .map((group) => { const item = group.items.find((item) => item.url === route.currentUrl) return item ? [group.title, item.title] : null }) .filter(Boolean)[0] return ( }> {crumbs?.map((crumb, index) => {crumb})} ) } export const MobileSidebarNav = () => { const [isOpen, setIsOpen] = useState(false) const route = useRoute() const pathname = usePathname() const pathnameRef = useRef(pathname) const closeMenu = () => setIsOpen(false) useEffect(() => { if (pathnameRef.current !== pathname) { setIsOpen(false) } pathnameRef.current = pathname }, [pathname, setIsOpen]) return ( setIsOpen(e.open)} > {route .getSidebarNavItems() ?.map((group) => ( ))} ) }