import { ComponentPropsWithRef, ElementType, useRef } from "react"; import { DotLottie, DotLottieReact } from "@lottiefiles/dotlottie-react"; import { twMerge } from "tailwind-merge"; import { MenuItemProps } from "@app/components/v2"; export const MenuIconButton = ({ children, icon, className, isDisabled, isSelected, as: Item = "div", description, // wrapping in forward ref with generic component causes the loss of ts definitions on props inputRef, lottieIconMode = "forward", ...props }: MenuItemProps & ComponentPropsWithRef & { lottieIconMode?: "reverse" | "forward" }): JSX.Element => { const iconRef = useRef(null); return (
iconRef.current?.play()} onMouseLeave={() => iconRef.current?.stop()} ref={inputRef} {...props} >
{icon && (
{ iconRef.current = el; }} src={`/lotties/${icon}.json`} loop className="h-full w-full" mode={lottieIconMode} />
)}
{children}
); };