(props: { items: SideNavItem[], children?: ReactNode | ReactNode[] })
| 16 | const drawerWidth = 250; |
| 17 | |
| 18 | export function SideNav(props: { items: SideNavItem[], children?: ReactNode | ReactNode[] }) { |
| 19 | let sideNavController = UseSideNavController(); |
| 20 | |
| 21 | useEffect(() => { |
| 22 | sideNavController.addInstance(); |
| 23 | return function () { |
| 24 | sideNavController.removeInstance(); |
| 25 | } |
| 26 | |
| 27 | // this is fine even though it warns us |
| 28 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 29 | }, []) |
| 30 | |
| 31 | const drawerContents = ( |
| 32 | <> |
| 33 | <List> |
| 34 | {props.items.map((v, i) => ( |
| 35 | <NavItem item={v} key={i} /> |
| 36 | ))} |
| 37 | </List> |
| 38 | </> |
| 39 | ); |
| 40 | |
| 41 | // we move the top bar pages to the side bar to best utilize the space |
| 42 | const topBarReplacements = ( |
| 43 | <> |
| 44 | {TopBarNavPages.map((v, i) => ( |
| 45 | <NavItem item={{ |
| 46 | isNavLink: !v.useHref, |
| 47 | label: v.label, |
| 48 | path: v.path, |
| 49 | }} key={i} /> |
| 50 | ))} |
| 51 | </> |
| 52 | ) |
| 53 | |
| 54 | const container = window !== undefined ? () => window.document.body : undefined; |
| 55 | |
| 56 | return <Box |
| 57 | component="nav" |
| 58 | sx={{ width: { md: drawerWidth }, flexShrink: { md: 0 } }} |
| 59 | aria-label="mailbox folders" |
| 60 | > |
| 61 | {/* The implementation can be swapped with js to avoid SEO duplication of links. */} |
| 62 | <Drawer |
| 63 | container={container} |
| 64 | variant="temporary" |
| 65 | open={sideNavController.isOpen} |
| 66 | onClose={sideNavController.close} |
| 67 | ModalProps={{ |
| 68 | keepMounted: true, // Better open performance on mobile. |
| 69 | }} |
| 70 | sx={{ |
| 71 | display: { xs: 'block', md: 'none' }, |
| 72 | '& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth }, |
| 73 | }} |
| 74 | > |
| 75 | <Toolbar >{":)"}</Toolbar> |
nothing calls this directly
no test coverage detected