'use client'; import Link from 'next/link'; import Image from 'next/image'; import { useTranslations } from 'next-intl'; import { usePathname } from 'next/navigation'; import { Button } from './ui'; import { useEffect, useState } from 'react'; import { cn } from './ui'; export default function Header() { const t = useTranslations('Navigation'); const pathname = usePathname(); const [isScrolled, setIsScrolled] = useState(false); // Extract locale from pathname const currentLocale = pathname.split('/')[1] || 'en'; // Check if homepage const isHomePage = pathname === `/${currentLocale}` || pathname === '/'; useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 50); }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); // Function to get path for a different locale const getPathForLocale = (newLocale: string) => { const segments = pathname.split('/'); segments[1] = newLocale; return segments.join('/'); }; const menuItems = [ { label: t('home'), href: '/' }, { label: t('team'), href: '/team' }, { label: t('products'), href: '/products' }, { label: t('blog'), href: '/blog' }, ]; const headerClass = cn( "fixed top-0 left-0 right-0 z-50 transition-all duration-300", { "bg-transparent": isHomePage && !isScrolled, "bg-white shadow-md": !isHomePage || isScrolled, "py-4": !isScrolled, "py-2": isScrolled } ); const textColorClass = (isHomePage && !isScrolled) ? "text-white" : "text-text-primary"; const logoSrc = (isHomePage && !isScrolled) ? "/logo-white.svg" : "/logo-blue.svg"; return ( <>
KLZ Cables
English Deutsch
{/* Mobile Menu Button */}
{!isHomePage &&
} ); }