diff --git a/src/components/layout/mega-dropdown.tsx b/src/components/layout/mega-dropdown.tsx new file mode 100644 index 0000000..9b30c2b --- /dev/null +++ b/src/components/layout/mega-dropdown.tsx @@ -0,0 +1,69 @@ +'use client'; + +import { useRef, useEffect } from 'react'; +import { ChevronDown } from 'lucide-react'; +import { AnimatePresence, motion } from 'framer-motion'; +import { StaticLink } from '@/components/ui/static-link'; +import type { MegaDropdownItem } from '@/lib/constants'; + +interface MegaDropdownProps { + label: string; + items: MegaDropdownItem[]; + isOpen: boolean; + onToggle: () => void; +} + +export function MegaDropdown({ label, items, isOpen, onToggle }: MegaDropdownProps) { + const dropdownRef = useRef(null); + + useEffect(() => { + function handleClickOutside(event: MouseEvent) { + if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) { + if (isOpen) { onToggle(); } + } + } + document.addEventListener('mousedown', handleClickOutside); + return () => document.removeEventListener('mousedown', handleClickOutside); + }, [isOpen, onToggle]); + + return ( +
+ + + + {isOpen && ( + +
+ {items.map((item) => ( + +
{item.title}
+
{item.description}
+
+ ))} +
+
+ )} +
+
+ ); +}