"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"); const isArabic = locale === "ar"; const desktopControlRailClassName = "inline-flex items-center gap-1 rounded-[var(--radius-pill)] border border-black/6 bg-white/24 p-1 shadow-[0_14px_34px_-24px_rgba(15,23,42,0.18)] backdrop-blur-[18px] dark:border-white/10 dark:bg-white/4 dark:shadow-[0_20px_48px_-28px_rgba(0,0,0,0.58)]"; const desktopControlButtonClassName = "h-9 w-9 rounded-full border border-transparent p-0 text-[hsl(var(--hero-ink)/0.76)] hover:border-black/5 hover:bg-white/36 hover:text-[hsl(var(--hero-ink))] dark:text-foreground dark:hover:border-white/10 dark:hover:bg-white/10"; const mobileControlButtonClassName = "h-10 w-10 rounded-full border border-black/6 bg-white/32 p-0 text-[hsl(var(--hero-ink)/0.8)] hover:bg-white/42 hover:text-[hsl(var(--hero-ink))] dark:border-white/10 dark:bg-white/6 dark:text-foreground dark:hover:bg-white/10"; return (
{isAdmin ? ( ) : null}
{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 ? ( ) : null}
) : null}
); }