import { ChevronUpIcon } from "@chakra-ui/icons"; import { Box, Button, Drawer, DrawerBody, DrawerOverlay, DrawerHeader, DrawerContent, DrawerCloseButton, Flex, useDisclosure, Portal, } from "@chakra-ui/react"; import { FunctionComponent, useEffect } from "react"; import { useLocation } from "react-router-dom"; import { ChooseSubmodule } from "./ChooseSubmodule"; import { usePackageState } from "./PackageState"; import { NavTree } from "../../components/NavTree"; export const NavDrawer: FunctionComponent = () => { const { assembly, menuItems } = usePackageState(); const drawer = useDisclosure(); const location = useLocation(); const hasSubmodules = Object.keys(assembly.data?.submodules ?? {}).length > 0; // Close NavDrawer when URL updates useEffect(() => { if (drawer.isOpen) { drawer.onClose(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [location]); return ( Table of contents {hasSubmodules && ( )} ); };