From 85fcb615d8e2126e60cc33a62640ef7d3be2d5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Thu, 30 Apr 2026 19:06:09 +0800 Subject: [PATCH] feat: add MegaDropdown component for product/solution matrix navigation --- src/components/layout/mega-dropdown.tsx | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/components/layout/mega-dropdown.tsx 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}
+
+ ))} +
+
+ )} +
+
+ ); +}