From 7517ec0b016265a6c1d35f22ba6292c498669d43 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Thu, 13 Nov 2025 19:37:04 +0900 Subject: (김준회) 헤더 메뉴: 클릭으로 토글하는 방식으로 변경 (설계측 요청사항) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/layout/Header.tsx | 51 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'components/layout/Header.tsx') diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx index c5c83e64..b3d9ee6a 100644 --- a/components/layout/Header.tsx +++ b/components/layout/Header.tsx @@ -3,7 +3,6 @@ import * as React from "react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"; import { DropdownMenu, @@ -22,7 +21,7 @@ import { NavigationMenuTrigger, navigationMenuTriggerStyle, } from "@/components/ui/navigation-menu"; -import { SearchIcon, BellIcon, Menu } from "lucide-react"; +import { SearchIcon } from "lucide-react"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { cn } from "@/lib/utils"; import Image from "next/image"; @@ -34,7 +33,6 @@ import { salesNav, engineeringNav, MenuSection, - MenuItem, mainNavVendor, additionalNavVendor, domainBrandingKeys @@ -58,20 +56,29 @@ export function Header() { const userName = session?.user?.name || ""; - const domain = session?.user?.domain || ""; const initials = userName .split(" ") .map((word) => word[0]?.toUpperCase()) .join(""); const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false); + const [openMenuKey, setOpenMenuKey] = React.useState(""); const toggleMobileMenu = () => { setIsMobileMenuOpen(!isMobileMenuOpen); }; + const toggleMenu = React.useCallback((menuKey: string) => { + setOpenMenuKey(prev => prev === menuKey ? "" : menuKey); + }, []); + + // 페이지 이동 시 메뉴 닫기 + React.useEffect(() => { + setOpenMenuKey(""); + }, [pathname]); + // 도메인별 메뉴 및 브랜딩 정보 가져오기 - const getDomainConfig = (pathname: string) => { + const getDomainConfig = (pathname: string | null) => { if (pathname?.includes("/partners")) { return { main: mainNavVendor, @@ -175,18 +182,35 @@ export function Header() { {/* 네비게이션 메뉴 - 도메인별 활성화된 메뉴만 표시 (번역된) */}
- +
{main.map((section: MenuSection) => ( - - + + { + e.preventDefault(); + e.stopPropagation(); + toggleMenu(section.titleKey); + }} + onPointerEnter={(e) => e.preventDefault()} + onPointerMove={(e) => e.preventDefault()} + > {t(section.titleKey)} {/* 그룹핑이 필요한 메뉴의 경우 GroupedMenuRenderer 사용 */} {section.useGrouping ? ( - + e.preventDefault()} + onPointerLeave={(e) => e.preventDefault()} + forceMount={openMenuKey === section.titleKey ? true : undefined} + > ) : ( - + e.preventDefault()} + onPointerLeave={(e) => e.preventDefault()} + forceMount={openMenuKey === section.titleKey ? true : undefined} + >
    {section.items.map((item) => ( { console.log("[URL]", path + (qs ? "?" + qs : "")); }, [path, qs]); -- cgit v1.2.3