import { Fragment, useRef } from 'react' import { Popover, Transition } from '@headlessui/react' import { ChevronDownIcon } from '@heroicons/react/solid' import Link from 'next/link' type NavDropMenuProps = { menuTitle: string | React.ReactNode linksArray: [string, string, boolean, React.ReactNode][] } export default function NavDropMenu({ menuTitle = '', linksArray = [], }: NavDropMenuProps) { const buttonRef = useRef(null) const toggleMenu = () => { buttonRef?.current?.click() } const onHover = (open, action) => { if ( (!open && action === 'onMouseEnter') || (open && action === 'onMouseLeave') ) { toggleMenu() } } return ( {({ open }) => (
onHover(open, 'onMouseEnter')} onMouseLeave={() => onHover(open, 'onMouseLeave')} className="flex flex-col" >
{menuTitle}
{linksArray.map(([name, href, isExternal, icon]) => !isExternal ? ( {icon ?
{icon}
: null} {name}
) : ( {icon ?
{icon}
: null} {name}
) )}
)}
) }