import React from "react"; import styled from "styled-components"; import { useLocation } from "react-router-dom"; import { SvgProps } from "../../../components/Svg"; import * as IconModule from "../icons"; import Accordion from "./Accordion"; import { MenuEntry, LinkLabel, LinkStatus } from "./MenuEntry"; import MenuLink from "./MenuLink"; import { PanelProps, PushedProps } from "../types"; interface Props extends PanelProps, PushedProps { isMobile: boolean; } const Icons = (IconModule as unknown) as { [key: string]: React.FC }; const Container = styled.div` display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; height: 100%; `; const PanelBody: React.FC = ({ isPushed, pushNav, isMobile, links }) => { const location = useLocation(); // Close the menu when a user clicks a link on mobile const handleClick = isMobile ? () => pushNav(false) : undefined; return ( {links.map((entry) => { const Icon = Icons[entry.icon]; const iconElement = ; const calloutClass = entry.calloutClass ? entry.calloutClass : undefined; if (entry.items) { const itemsMatchIndex = entry.items.findIndex((item) => item.href === location.pathname); const initialOpenState = entry.initialOpenState === true ? entry.initialOpenState : itemsMatchIndex >= 0; return ( item.href === location.pathname)} > {isPushed && entry.items.map((item) => ( {item.label} {item.status && ( {item.status.text} )} ))} ); } return ( {iconElement} {entry.label} {entry.status && ( {entry.status.text} )} ); })} ); }; export default PanelBody;