"use client"; import { AnimatePresence, motion } from "framer-motion"; import { LayoutDashboard, Menu, X } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useLocale, useTranslations } from "next-intl"; import { useState } from "react"; import { Container } from "@/components/layout/container"; import { LocaleToggle } from "@/components/layout/locale-toggle"; import { SiteLogo } from "@/components/layout/site-logo"; import { ThemeToggle } from "@/components/theme-toggle"; import { Button } from "@/components/ui/button"; import { getLocalizedPath, stripLocalePrefix } from "@/lib/locale"; import { cn } from "@/lib/utils"; const navItems = [ { key: "home", path: "" }, { key: "portfolio", path: "/portfolio" }, { key: "products", path: "/products" }, { key: "about", path: "/about" }, { key: "contact", path: "/contact" }, ]; type SiteHeaderProps = { isAdmin?: boolean; lightLogoUrl?: string | null; darkLogoUrl?: string | null; }; function isNavItemActive(currentPath: string, itemPath: string) { if (itemPath === "/") { return currentPath === "/"; } return currentPath === itemPath || currentPath.startsWith(`${itemPath}/`); } function NavLinks({ onNavigate, mobile = false, }: { onNavigate?: () => void; mobile?: boolean; }) { const locale = useLocale(); const pathname = usePathname(); const t = useTranslations("navigation"); const currentPath = stripLocalePrefix(pathname); return ( <> {navItems.map((item) => ( (() => { const itemPath = item.path || "/"; const isActive = isNavItemActive(currentPath, itemPath); return ( {isActive ? ( ) : null} {t(item.key)} ); })() ))} > ); } export function SiteHeader({ isAdmin = false, lightLogoUrl, darkLogoUrl, }: SiteHeaderProps) { const [isOpen, setIsOpen] = useState(false); const pathname = usePathname(); const locale = useLocale(); const t = useTranslations("navigation"); return ( {isAdmin ? ( ) : null} setIsOpen((open) => !open)} variant="ghost" size="icon" className="ml-auto h-11 w-11 rounded-[var(--radius-pill)] border border-white/18 bg-white/12 text-foreground shadow-[0_18px_44px_-28px_rgba(15,23,42,0.24)] backdrop-blur-[24px] hover:bg-white/18 dark:border-white/10 dark:bg-white/5 dark:shadow-[0_20px_48px_-28px_rgba(0,0,0,0.58)] dark:hover:bg-white/10 lg:hidden" aria-label={isOpen ? t("closeMenu") : t("openMenu")} > {isOpen ? : } {isOpen ? ( {navItems.map((item) => { const itemPath = item.path || "/"; const isActive = isNavItemActive(stripLocalePrefix(pathname), itemPath); return ( setIsOpen(false)} > {t(item.key)} 0{navItems.findIndex((navItem) => navItem.key === item.key) + 1} ); })} {isAdmin ? ( setIsOpen(false)}> ) : null} ) : null} ); }