import React, { useState, useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Menu, X as CloseIcon } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; const Header = ({ navLinks, handleLogoClick: originalHandleLogoClick, isMobileMenuOpen, toggleMobileMenu, setIsMobileMenuOpen, toggleAdminPanel: triggerAdminPanelAction }) => { const [logoClickCount, setLogoClickCount] = useState(0); const [clickTimer, setClickTimer] = useState(null); const mobileMenuVariants = { hidden: { x: '-100%', opacity: 0, }, visible: { x: 0, opacity: 1, transition: { type: 'spring', stiffness: 260, damping: 30, }, }, exit: { x: '-100%', opacity: 0, transition: { duration: 0.3, }, }, }; const mobileNavLinks = [ { href: "https://alogapedia.com", text: "Home" }, { href: "/", text: "Deals" }, { href: "https://alogapedia.com/product-reviews/", text: "Reviews" }, { href: "https://alogapedia.com/recommendations/", text: "Recommendations" }, { href: "https://alogapedia.com/about/", text: "About" } ]; const handleExtendedLogoClick = () => { const newCount = logoClickCount + 1; setLogoClickCount(newCount); if (clickTimer) { clearTimeout(clickTimer); } if (newCount >= 5) { if (triggerAdminPanelAction) triggerAdminPanelAction(); setLogoClickCount(0); setClickTimer(null); } else { const newTimer = setTimeout(() => { if (newCount === 1 && originalHandleLogoClick) { originalHandleLogoClick(); } setLogoClickCount(0); }, newCount === 1 ? 300 : 2000); setClickTimer(newTimer); } }; useEffect(() => { return () => { if (clickTimer) { clearTimeout(clickTimer); } }; }, [clickTimer]); return (
Alogapedia Logo
Alogapedia Logo
{isMobileMenuOpen && (
Main Menu
{mobileNavLinks.map(link => ( setIsMobileMenuOpen(false)} aria-current={link.href === window.location.pathname ? 'page' : undefined} > {link.text} ))}
)}
); }; export default React.memo(Header);