"use client"; import React, { useState, useEffect, useRef } from "react"; import { cn } from "../../lib/utils"; import { Menu, X } from "lucide-react"; export interface MenuItem { label: string; href?: string; onClick?: () => void; icon?: React.ReactNode; } export interface HamburgerMenuOverlayProps { /** Array of menu items */ items: MenuItem[]; /** Button position from top */ buttonTop?: string; /** Button position from left */ buttonLeft?: string; /** Button size */ buttonSize?: "sm" | "md" | "lg"; /** Button background color */ buttonColor?: string; /** Overlay background color/gradient */ overlayBackground?: string; /** Menu text color */ textColor?: string; /** Menu font size */ fontSize?: "sm" | "md" | "lg" | "xl" | "2xl"; /** Font family */ fontFamily?: string; /** Font weight */ fontWeight?: "normal" | "medium" | "semibold" | "bold"; /** Animation duration in seconds */ animationDuration?: number; /** Stagger delay between menu items */ staggerDelay?: number; /** Menu items alignment */ menuAlignment?: "left" | "center" | "right"; /** Custom class for container */ className?: string; /** Custom class for button */ buttonClassName?: string; /** Custom class for menu items */ menuItemClassName?: string; /** Disable overlay close on item click */ keepOpenOnItemClick?: boolean; /** Custom button content */ customButton?: React.ReactNode; /** ARIA label for accessibility */ ariaLabel?: string; /** Callback when menu opens */ onOpen?: () => void; /** Callback when menu closes */ onClose?: () => void; /** Menu items layout direction */ menuDirection?: "vertical" | "horizontal"; /** Enable blur backdrop */ enableBlur?: boolean; /** Z-index for overlay */ zIndex?: number; } export const HamburgerMenuOverlay: React.FC = ({ items = [], buttonTop = "60px", buttonLeft = "60px", buttonSize = "md", buttonColor = "#6c8cff", overlayBackground = "#6c8cff", textColor = "#ffffff", fontSize = "md", fontFamily = '"Krona One", monospace', fontWeight = "bold", animationDuration = 1.5, staggerDelay = 0.1, menuAlignment = "left", className, buttonClassName, menuItemClassName, keepOpenOnItemClick = false, customButton, ariaLabel = "Navigation menu", onOpen, onClose, menuDirection = "vertical", enableBlur = false, zIndex = 1000, }) => { const [isOpen, setIsOpen] = useState(false); const navRef = useRef(null); const containerRef = useRef(null); const buttonSizes = { sm: "w-10 h-10", md: "w-12 h-12", lg: "w-16 h-16", }; const fontSizes = { sm: "text-2xl md:text-3xl", md: "text-3xl md:text-4xl", lg: "text-4xl md:text-5xl", xl: "text-5xl md:text-6xl", "2xl": "text-6xl md:text-7xl", }; const toggleMenu = () => { const newState = !isOpen; setIsOpen(newState); if (newState) { onOpen?.(); } else { onClose?.(); } }; const handleItemClick = (item: MenuItem) => { if (item.onClick) { item.onClick(); } if (item.href && !item.onClick) { window.location.href = item.href; } if (!keepOpenOnItemClick) { setIsOpen(false); onClose?.(); } }; // Close menu on escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === "Escape" && isOpen) { setIsOpen(false); onClose?.(); } }; document.addEventListener("keydown", handleEscape); return () => document.removeEventListener("keydown", handleEscape); }, [isOpen, onClose]); return (
{/* Navigation Overlay */}
    {items.map((item, index) => (
  • handleItemClick(item)} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); handleItemClick(item); } }} tabIndex={isOpen ? 0 : -1} role="button" aria-label={`Navigate to ${item.label}`} > {item.icon && {item.icon}} {item.label}
  • ))}
{/* Hamburger Button */}
); }; export default HamburgerMenuOverlay;