"use client"; import { useState, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { Menu, X, Mail } from "lucide-react"; import { SiGithub, SiLinkedin } from "react-icons/si"; import Link from "next/link"; import { usePathname, useSearchParams } from "next/navigation"; import type { NavTranslations } from "@/types/translations"; interface HeaderClientProps { locale: string; translations: NavTranslations; } export default function HeaderClient({ locale, translations }: HeaderClientProps) { const [isOpen, setIsOpen] = useState(false); const [scrolled, setScrolled] = useState(false); const pathname = usePathname(); const searchParams = useSearchParams(); const isHome = pathname === `/${locale}` || pathname === `/${locale}/`; useEffect(() => { const handleScroll = () => { setScrolled(window.scrollY > 50); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const navItems = [ { name: translations.home, href: `/${locale}` }, { name: translations.about, href: isHome ? "#about" : `/${locale}#about` }, { name: translations.projects, href: isHome ? "#projects" : `/${locale}/projects` }, { name: translations.contact, href: isHome ? "#contact" : `/${locale}#contact` }, ]; const socialLinks = [ { icon: SiGithub, href: "https://github.com/Denshooter", label: "GitHub" }, { icon: SiLinkedin, href: "https://linkedin.com/in/dkonkol", label: "LinkedIn", }, { icon: Mail, href: "mailto:contact@dk0.dev", label: "Email" }, ]; const pathWithoutLocale = pathname.replace(new RegExp(`^/${locale}`), "") || ""; const qs = searchParams.toString(); const query = qs ? `?${qs}` : ""; const enHref = `/en${pathWithoutLocale}${query}`; const deHref = `/de${pathWithoutLocale}${query}`; return ( <>
dk0 setIsOpen(!isOpen)} className="md:hidden p-2 rounded-lg bg-stone-100 hover:bg-stone-200 text-stone-700 transition-colors" aria-label="Toggle menu" > {isOpen ? : }
{isOpen && ( setIsOpen(false)} /> )} {isOpen && (
setIsOpen(false)} > dk0
{/* Language Switcher Mobile */}
setIsOpen(false)} className={`flex-1 px-4 py-2 text-center font-medium rounded-lg transition-all ${ locale === "en" ? "bg-stone-900 text-white" : "bg-stone-100 text-stone-600 hover:bg-stone-200" }`} > EN setIsOpen(false)} className={`flex-1 px-4 py-2 text-center font-medium rounded-lg transition-all ${ locale === "de" ? "bg-stone-900 text-white" : "bg-stone-100 text-stone-600 hover:bg-stone-200" }`} > DE
{socialLinks.map((link) => { const Icon = link.icon; return ( ); })}
)}
); }