'use client'; import { useEffect, useState } from 'react'; import { useTranslations, useLocale } from 'next-intl'; import { Menu, X, Home, User, Briefcase, BookOpen, Phone, Cog, } from 'lucide-react'; import Link from 'next/link'; import Image from 'next/image'; import { usePathname } from 'next/navigation'; import { NavLink } from './NavLink'; import LanguageSwitcher from './LanguageSwitcher'; import { ContactInfo } from './ContactInfo'; import { throttle } from '@/utils/throttle'; const Header = () => { const t = useTranslations('navigation'); const locale = useLocale(); const pathname = usePathname(); const [scrolled, setScrolled] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); // Close menu on route change useEffect(() => { setIsMenuOpen(false); }, [pathname]); // Scroll handler useEffect(() => { const handleScroll = throttle(() => { setScrolled(window.scrollY > 0); }, 100); window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); // Prevent body scroll when menu is open useEffect(() => { if (isMenuOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [isMenuOpen]); const navigationLinks = [ { path: `/${locale}`, label: t('main.home'), icon: , }, { path: `/${locale}/about`, label: t('main.about'), icon: , }, { path: `/${locale}/leistungen`, label: t('main.services'), icon: , }, { path: `/${locale}/portfolio`, label: t('main.portfolio'), icon: , }, { path: `/${locale}/blog`, label: t('main.blog'), icon: , }, { path: `/${locale}/contact`, label: t('main.contact'), icon: , }, ]; return ( <> {/* Navigation */} {/* Mobile Menu Backdrop */}
setIsMenuOpen(false)} /> {/* Mobile Sidebar */}
{/* Sidebar Header */}
Menu
{/* Scrollable Sidebar Content */}
{/* Contact Info */} {/* Navigation Links */}
{navigationLinks.map(({ path, label, icon }) => ( setIsMenuOpen(false)} className="flex items-center w-full mb-1" /> ))}
{/* Language Switcher */}
Sprache ändern
); }; export default Header;