= ({
item,
toggleOpen,
}) => {
const pathname = usePathname();
const [subMenuOpen, setSubMenuOpen] = useState(false);
return (
<>
{subMenuOpen && (
<>
{item.subMenuItems?.map((subItem, subIdx) => {
return (
);
})}
>
)}
>
);
};
const MenuItemVariants = {
open: {
y: 0,
opacity: 1,
transition: {
y: { stiffness: 1000, velocity: -100 },
},
},
closed: {
y: 50,
opacity: 0,
transition: {
y: { stiffness: 1000 },
duration: 0.02,
},
},
};
const variants = {
open: {
transition: { staggerChildren: 0.02, delayChildren: 0.15 },
},
closed: {
transition: { staggerChildren: 0.01, staggerDirection: -1 },
},
};
const useDimensions = (ref: any) => {
const dimensions = useRef({ width: 0, height: 0 });
useEffect(() => {
if (ref.current) {
dimensions.current.width = ref.current.offsetWidth;
dimensions.current.height = ref.current.offsetHeight;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ref]);
return dimensions.current;
};