"use client"; import { useState, useEffect, useRef } from "react"; import Link from "next/link"; import { usePathname, useSearchParams } from "next/navigation"; import type { NavTranslations } from "@/types/translations"; import { ThemeToggle } from "./ThemeToggle"; const SiGithubIcon = ({ size = 20 }: { size?: number }) => ( ); const SiLinkedinIcon = ({ size = 20 }: { size?: number }) => ( ); // Inline SVG icons to avoid loading the full lucide-react chunk (~116KB) const MenuIcon = ({ size = 24 }: { size?: number }) => ( ); const XIcon = ({ size = 24 }: { size?: number }) => ( ); const MailIcon = ({ size = 20 }: { size?: number }) => ( ); 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 prevLocale = useRef(locale); useEffect(() => { if (prevLocale.current !== locale) { window.scrollTo({ top: 0, behavior: "instant" }); prevLocale.current = locale; } }, [locale]); 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: SiGithubIcon, href: "https://github.com/Denshooter", label: "GitHub" }, { icon: SiLinkedinIcon, href: "https://linkedin.com/in/dkonkol", label: "LinkedIn", }, { icon: MailIcon, 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
{/* Mobile menu overlay */} {isOpen && (
setIsOpen(false)} /> )} {/* Mobile menu panel */} {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 ( ); })}
)} ); }