'use client'; import Link from 'next/link'; import Image from 'next/image'; import { motion } from 'framer-motion'; 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); const [isMobileMenuOpen, setIsMobileMenuOpen] = 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); }, []); // Prevent scroll when mobile menu is open useEffect(() => { if (isMobileMenuOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = 'unset'; } }, [isMobileMenuOpen]); // 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-500 safe-area-p transform-gpu', { 'bg-transparent py-4 md:py-8': isHomePage && !isScrolled && !isMobileMenuOpen, 'bg-primary py-3 md:py-4 shadow-2xl': !isHomePage || isScrolled || isMobileMenuOpen, }, ); const textColorClass = 'text-white'; const logoSrc = '/logo-white.svg'; return ( <>
{t('home')} {menuItems.map((item, _idx) => ( setIsMobileMenuOpen(false)} className={cn( textColorClass, 'hover:text-accent font-bold transition-all duration-500 text-base md:text-lg tracking-tight relative group inline-block hover:-translate-y-0.5', )} > {item.label} ))} EN DE {/* Mobile Menu Button */} setIsMobileMenuOpen(!isMobileMenuOpen)} > {isMobileMenuOpen ? ( ) : ( )}
{/* Mobile Menu Overlay */}
{menuItems.map((item, idx) => ( setIsMobileMenuOpen(false)} className="text-2xl md:text-3xl font-extrabold text-white hover:text-accent transition-all transform block py-4" > {item.label} ))} EN DE {/* Bottom Branding */} {t('home')}
); } const navVariants = { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.06, delayChildren: 0.1, }, }, } as const; const navLinkVariants = { hidden: { opacity: 0, y: 20, scale: 0.9 }, visible: { opacity: 1, y: 0, scale: 1, transition: { duration: 0.5, ease: 'easeOut', }, }, } as const; const headerRightVariants = { hidden: { opacity: 0, x: 30 }, visible: { opacity: 1, x: 0, transition: { duration: 0.6, ease: 'easeOut' }, }, } as const;