import React, { useState, useRef } from 'react'; import { ChevronRightIcon } from '../../assets/icons/ChevronRightIcon'; interface QuickLink { label: string; href: string; external?: boolean; } const actionPanelSiteLinks: QuickLink[] = [ { label: 'Website', href: 'https://actionpanelai.com/', external: true }, { label: 'Privacy', href: 'https://actionpanelai.com/privacy', external: true }, { label: 'Terms', href: 'https://actionpanelai.com/terms', external: true }, ]; const QuickLinks: React.FC = () => { const [isOpen, setIsOpen] = useState(false); const timeoutRef = useRef(); // Optionally, detect if it's a mobile device const isMobile = window.matchMedia('(pointer: coarse)').matches; const handleMouseEnter = () => { // Show dropdown only if it's not a mobile device if (!isMobile) { if (timeoutRef.current) { clearTimeout(timeoutRef.current); } setIsOpen(true); } }; const handleMouseLeave = () => { if (!isMobile) { timeoutRef.current = setTimeout(() => { setIsOpen(false); }, 75); } }; const handleClick = () => { // If it is mobile, toggle on click if (isMobile) { setIsOpen(!isOpen); } }; return (
{/* Desktop menu */} {isOpen && !isMobile && (
{actionPanelSiteLinks.map((link) => ( {link.label} ))}
)} {/* Mobile menu */} {isOpen && isMobile && (
{actionPanelSiteLinks.map((link) => ( {link.label} ))}
)}
); }; export default React.memo(QuickLinks);