All checks were successful
Gitea CI / test-build (push) Successful in 11m36s
- Remove framer-motion from Hero.tsx and HeaderClient.tsx, replace with CSS animations/transitions - Replace lucide-react icons (Menu, X, Mail) with inline SVGs in HeaderClient.tsx - Lazy-load About, Projects, Contact, Footer via dynamic() imports in ClientWrappers.tsx - Defer ShaderGradient/BackgroundBlobs loading via requestIdleCallback in ClientProviders.tsx - Remove AnimatePresence page wrapper that caused full re-renders - Enable experimental.optimizeCss (critters) for critical CSS inlining - Add fadeIn keyframe to Tailwind config for CSS-based animations Homepage JS reduced from 563KB to 438KB (-125KB). Eliminates ~39s main thread work from WebGL init and layout thrashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
232 lines
9.0 KiB
TypeScript
232 lines
9.0 KiB
TypeScript
"use client";
|
|
|
|
import { useState, useEffect } from "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";
|
|
|
|
// Inline SVG icons to avoid loading the full lucide-react chunk (~116KB)
|
|
const MenuIcon = ({ size = 24 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>
|
|
);
|
|
const XIcon = ({ size = 24 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
);
|
|
const MailIcon = ({ size = 20 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg>
|
|
);
|
|
|
|
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: 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 (
|
|
<>
|
|
<header className="fixed top-6 left-0 right-0 z-50 flex justify-center px-4 pointer-events-none">
|
|
<div
|
|
className={`pointer-events-auto transition-all duration-500 ease-out ${
|
|
scrolled ? "w-full max-w-5xl" : "w-full max-w-7xl"
|
|
}`}
|
|
>
|
|
<div
|
|
className={`backdrop-blur-xl transition-all duration-500 flex justify-between items-center ${
|
|
scrolled
|
|
? "bg-white/95 border border-stone-200/50 shadow-[0_8px_30px_rgba(0,0,0,0.12)] rounded-full px-6 py-3"
|
|
: "bg-white/85 border border-stone-200/30 shadow-[0_4px_24px_rgba(0,0,0,0.08)] px-4 py-4 rounded-full"
|
|
}`}
|
|
>
|
|
<div className="flex items-center space-x-2 hover:scale-105 transition-transform">
|
|
<Link
|
|
href={`/${locale}`}
|
|
className="text-2xl font-black font-sans text-stone-900 tracking-tighter liquid-hover flex items-center"
|
|
>
|
|
dk<span className="text-red-500">0</span>
|
|
</Link>
|
|
</div>
|
|
|
|
<nav className="hidden md:flex items-center space-x-8">
|
|
{navItems.map((item) => (
|
|
<div key={item.name} className="hover:-translate-y-0.5 active:scale-95 transition-all">
|
|
<Link
|
|
href={item.href}
|
|
className="text-stone-700 hover:text-stone-900 font-medium transition-colors relative liquid-hover"
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
</div>
|
|
))}
|
|
|
|
{/* Language Switcher */}
|
|
<div className="flex items-center space-x-2 ml-4 pl-4 border-l border-stone-300">
|
|
<Link
|
|
href={enHref}
|
|
className={`px-2 py-1 text-sm font-medium rounded transition-all ${
|
|
locale === "en"
|
|
? "bg-stone-900 text-white"
|
|
: "text-stone-600 hover:text-stone-900 hover:bg-stone-100"
|
|
}`}
|
|
>
|
|
EN
|
|
</Link>
|
|
<Link
|
|
href={deHref}
|
|
className={`px-2 py-1 text-sm font-medium rounded transition-all ${
|
|
locale === "de"
|
|
? "bg-stone-900 text-white"
|
|
: "text-stone-600 hover:text-stone-900 hover:bg-stone-100"
|
|
}`}
|
|
>
|
|
DE
|
|
</Link>
|
|
</div>
|
|
</nav>
|
|
|
|
<button
|
|
onClick={() => setIsOpen(!isOpen)}
|
|
className="md:hidden p-2 rounded-lg bg-stone-100 hover:bg-stone-200 text-stone-700 transition-all hover:scale-105 active:scale-95"
|
|
aria-label="Toggle menu"
|
|
>
|
|
{isOpen ? <XIcon size={24} /> : <MenuIcon size={24} />}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
{/* Mobile menu overlay */}
|
|
<div
|
|
className={`fixed inset-0 bg-stone-900/50 backdrop-blur-sm z-40 md:hidden transition-opacity duration-200 ${
|
|
isOpen ? "opacity-100" : "opacity-0 pointer-events-none"
|
|
}`}
|
|
onClick={() => setIsOpen(false)}
|
|
/>
|
|
|
|
{/* Mobile menu panel */}
|
|
<div
|
|
className={`fixed right-0 top-0 h-full w-80 bg-white shadow-2xl z-50 md:hidden overflow-y-auto transition-transform duration-300 ease-out ${
|
|
isOpen ? "translate-x-0" : "translate-x-full"
|
|
}`}
|
|
>
|
|
<div className="p-6">
|
|
<div className="flex justify-between items-center mb-8">
|
|
<Link
|
|
href={`/${locale}`}
|
|
className="text-2xl font-black text-stone-900"
|
|
onClick={() => setIsOpen(false)}
|
|
>
|
|
dk<span className="text-red-500">0</span>
|
|
</Link>
|
|
<button
|
|
onClick={() => setIsOpen(false)}
|
|
className="p-2 rounded-lg bg-stone-100 hover:bg-stone-200 text-stone-700"
|
|
aria-label="Close menu"
|
|
>
|
|
<XIcon size={24} />
|
|
</button>
|
|
</div>
|
|
|
|
<nav className="space-y-2">
|
|
{navItems.map((item) => (
|
|
<Link
|
|
key={item.name}
|
|
href={item.href}
|
|
onClick={() => setIsOpen(false)}
|
|
className="block px-4 py-3 text-stone-700 hover:bg-stone-50 rounded-lg font-medium transition-colors"
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
))}
|
|
</nav>
|
|
|
|
{/* Language Switcher Mobile */}
|
|
<div className="flex gap-2 mt-6 pt-6 border-t border-stone-200">
|
|
<Link
|
|
href={enHref}
|
|
onClick={() => 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
|
|
</Link>
|
|
<Link
|
|
href={deHref}
|
|
onClick={() => 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
|
|
</Link>
|
|
</div>
|
|
|
|
<div className="mt-8 pt-6 border-t border-stone-200">
|
|
<div className="flex justify-center space-x-6">
|
|
{socialLinks.map((link) => {
|
|
const Icon = link.icon;
|
|
return (
|
|
<a
|
|
key={link.label}
|
|
href={link.href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="p-3 rounded-lg bg-stone-100 hover:bg-stone-900 hover:text-white text-stone-700 transition-all"
|
|
aria-label={link.label}
|
|
>
|
|
<Icon size={20} />
|
|
</a>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|