import { FC, ReactNode, useState } from 'react'; import { Box, ButtonBase, Container } from '@mui/material'; import { HeaderHeight } from './types'; import { Color } from '../../palette'; import { Card } from '../Card'; import { useRouter } from 'next/router'; import Link from 'next/link'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; type HeaderMenuItemProps = { label: string; href: string; selected?: boolean; children?: ReactNode | undefined; }; export const HeaderMenuItem: FC = ({ label, href, selected, children }) => { const { asPath } = useRouter(); const [open, setOpen] = useState(false); const useBorder = (color: string) => `2px solid ${selected || href === asPath || open ? Color.orange : color}`; const button = ( {label} {children && ( {open ? ( ) : ( )} )} ); return ( <> {children ? ( setOpen(!open)}> {button} ) : ( {button} )} {open && ( {children} )} ); };