455 lines
17 KiB
TypeScript
455 lines
17 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import Image from "next/image";
|
|
import { useState, useEffect, useRef } from "react";
|
|
import { gsap } from "gsap";
|
|
import { siteConfig } from "@/lib/site.config";
|
|
import DemoButton from "@/components/ui/DemoButton";
|
|
|
|
const productIconByHref: Record<string, string> = {
|
|
"/produkt/workflow-engine": "/icons/products/workflow-engine@4x.png",
|
|
"/produkt/email-marketing": "/icons/products/email-marketing@4x.png",
|
|
"/produkt/chat": "/icons/products/chat-app@4x.png",
|
|
"/produkt/projektmanagement": "/icons/products/projektmanagement@4x.png",
|
|
"/produkt/vertriebspipelines": "/icons/products/vertriebspipelines@4x.png",
|
|
"/produkt/mitarbeitermanagement": "/icons/products/mitarbeitermanagement@4x.png",
|
|
};
|
|
|
|
const glassSurfaceStyle = {
|
|
background: "rgba(255,255,255,0.54)",
|
|
backdropFilter: "blur(12px) saturate(140%)",
|
|
WebkitBackdropFilter: "blur(12px) saturate(140%)",
|
|
} as const;
|
|
|
|
const glassHighlightStyle = {
|
|
background:
|
|
"linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.08) 100%)",
|
|
} as const;
|
|
|
|
type NavbarProps = {
|
|
loginHref: string;
|
|
};
|
|
|
|
export default function Navbar({ loginHref }: NavbarProps) {
|
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
const [productsOpen, setProductsOpen] = useState(false);
|
|
const [dropdownMounted, setDropdownMounted] = useState(false);
|
|
const [scrolled, setScrolled] = useState(false);
|
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
const dropdownPanelRef = useRef<HTMLDivElement>(null);
|
|
const dropdownCloseTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
|
|
const clearDropdownCloseTimeout = () => {
|
|
if (dropdownCloseTimeoutRef.current) {
|
|
clearTimeout(dropdownCloseTimeoutRef.current);
|
|
dropdownCloseTimeoutRef.current = null;
|
|
}
|
|
};
|
|
|
|
const openProductsDropdown = () => {
|
|
clearDropdownCloseTimeout();
|
|
setDropdownMounted(true);
|
|
setProductsOpen(true);
|
|
};
|
|
|
|
const closeProductsDropdown = () => {
|
|
clearDropdownCloseTimeout();
|
|
dropdownCloseTimeoutRef.current = setTimeout(() => {
|
|
setProductsOpen(false);
|
|
}, 180);
|
|
};
|
|
|
|
useEffect(() => {
|
|
const onScroll = () => setScrolled(window.scrollY > 8);
|
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
return () => window.removeEventListener("scroll", onScroll);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
return () => clearDropdownCloseTimeout();
|
|
}, []);
|
|
|
|
// Close dropdown on outside click
|
|
useEffect(() => {
|
|
const handler = (e: MouseEvent) => {
|
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) {
|
|
clearDropdownCloseTimeout();
|
|
setProductsOpen(false);
|
|
}
|
|
};
|
|
document.addEventListener("mousedown", handler);
|
|
return () => document.removeEventListener("mousedown", handler);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (!productsOpen) return;
|
|
|
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
if (event.key === "Escape") {
|
|
clearDropdownCloseTimeout();
|
|
setProductsOpen(false);
|
|
}
|
|
};
|
|
|
|
document.addEventListener("keydown", onKeyDown);
|
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
}, [productsOpen]);
|
|
|
|
useEffect(() => {
|
|
if (!dropdownMounted || !dropdownPanelRef.current) return;
|
|
|
|
const panel = dropdownPanelRef.current;
|
|
gsap.killTweensOf(panel);
|
|
|
|
if (productsOpen) {
|
|
gsap.set(panel, { transformOrigin: "50% 0%", pointerEvents: "auto" });
|
|
gsap.fromTo(
|
|
panel,
|
|
{ autoAlpha: 0, scale: 0.94, y: -10 },
|
|
{ autoAlpha: 1, scale: 1, y: 0, duration: 0.24, ease: "power3.out" }
|
|
);
|
|
return;
|
|
}
|
|
|
|
gsap.to(panel, {
|
|
autoAlpha: 0,
|
|
scale: 0.94,
|
|
y: -10,
|
|
duration: 0.16,
|
|
ease: "power2.inOut",
|
|
onComplete: () => setDropdownMounted(false),
|
|
});
|
|
}, [productsOpen, dropdownMounted]);
|
|
|
|
// Close dropdown on scroll
|
|
useEffect(() => {
|
|
if (!productsOpen) return;
|
|
const onScroll = () => {
|
|
clearDropdownCloseTimeout();
|
|
setProductsOpen(false);
|
|
};
|
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
return () => window.removeEventListener("scroll", onScroll);
|
|
}, [productsOpen]);
|
|
|
|
// Lock body scroll when mobile menu is open
|
|
useEffect(() => {
|
|
document.body.style.overflow = mobileOpen ? "hidden" : "";
|
|
return () => { document.body.style.overflow = ""; };
|
|
}, [mobileOpen]);
|
|
|
|
return (
|
|
<>
|
|
<header
|
|
className="fixed top-0 left-0 right-0 z-50 transition-[background,box-shadow,border-color] duration-300"
|
|
style={{
|
|
height: 80,
|
|
...glassSurfaceStyle,
|
|
boxShadow: scrolled
|
|
? "0 10px 28px rgba(15, 23, 42, 0.10)"
|
|
: "0 3px 10px rgba(15, 23, 42, 0.06)",
|
|
borderBottom: scrolled ? "1px solid rgba(229, 229, 229, 0.9)" : "1px solid rgba(229, 229, 229, 0.55)",
|
|
}}
|
|
>
|
|
<div
|
|
className="pointer-events-none absolute inset-0"
|
|
style={glassHighlightStyle}
|
|
/>
|
|
|
|
<div
|
|
className="relative z-10 flex items-center justify-between w-full h-full"
|
|
style={{ paddingInline: "var(--side-padding-mobile)" }}
|
|
>
|
|
{/* Logo */}
|
|
<Link
|
|
href="/"
|
|
className="hover:opacity-80 transition-opacity"
|
|
>
|
|
<img src="/logo.svg" alt="HiveGrid" style={{ height: 36 }} />
|
|
</Link>
|
|
|
|
{/* Desktop Nav */}
|
|
<nav className="hidden lg:flex items-center gap-8">
|
|
{/* Produkte Dropdown */}
|
|
<div
|
|
className="relative"
|
|
ref={dropdownRef}
|
|
onMouseEnter={openProductsDropdown}
|
|
onMouseLeave={closeProductsDropdown}
|
|
>
|
|
<button
|
|
onClick={() => {
|
|
clearDropdownCloseTimeout();
|
|
if (!productsOpen) {
|
|
openProductsDropdown();
|
|
}
|
|
// If already open, clicking the button does nothing —
|
|
// dropdown closes only on outside click or scroll
|
|
}}
|
|
onFocus={openProductsDropdown}
|
|
aria-haspopup="menu"
|
|
aria-expanded={productsOpen}
|
|
className="flex items-center gap-1 text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
Lösungen
|
|
<svg
|
|
width="12"
|
|
height="12"
|
|
viewBox="0 0 12 12"
|
|
fill="none"
|
|
className={`transition-transform duration-200 ${productsOpen ? "rotate-180" : ""}`}
|
|
>
|
|
<path
|
|
d="M2 4L6 8L10 4"
|
|
stroke="currentColor"
|
|
strokeWidth="1.5"
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
|
|
{dropdownMounted && (
|
|
<div
|
|
className="fixed inset-x-0 top-[88px] z-[60] flex justify-center px-5"
|
|
onMouseEnter={openProductsDropdown}
|
|
onMouseLeave={closeProductsDropdown}
|
|
role="menu"
|
|
aria-label="Produkte"
|
|
>
|
|
<div
|
|
ref={dropdownPanelRef}
|
|
className="relative w-full max-w-[1080px] rounded-[12px] p-[50px] shadow-[0_10px_28px_rgba(15,23,42,0.10)]"
|
|
style={{
|
|
background: "#FFFFFF",
|
|
border: "1px solid rgba(229, 229, 229, 0.55)",
|
|
}}
|
|
>
|
|
<div className="relative z-10 grid grid-cols-3 gap-x-[30px] gap-y-12">
|
|
{siteConfig.produkte.map((p) => {
|
|
const iconSrc =
|
|
productIconByHref[p.href] ?? "/icons/products/workflow-engine@4x.png";
|
|
|
|
return (
|
|
<Link
|
|
key={p.href}
|
|
href={p.href}
|
|
onClick={() => {
|
|
clearDropdownCloseTimeout();
|
|
setProductsOpen(false);
|
|
}}
|
|
className="group grid grid-cols-[64px_1fr] gap-x-[10px] rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-yellow)]"
|
|
role="menuitem"
|
|
>
|
|
<span className="relative h-16 w-16 shrink-0 overflow-hidden rounded-[8px] shadow-sm">
|
|
<Image
|
|
src={iconSrc}
|
|
alt={`${p.label} Icon`}
|
|
width={64}
|
|
height={64}
|
|
className="h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.03]"
|
|
/>
|
|
</span>
|
|
|
|
<span className="flex min-w-0 flex-col justify-center">
|
|
<span className="inline-flex items-center gap-1 text-[16px] font-medium leading-[18px] tracking-[-0.02em] text-[var(--text-primary)] transition-colors group-hover:text-[var(--accent-teal)]">
|
|
{p.label}
|
|
<svg
|
|
width="6"
|
|
height="9"
|
|
viewBox="0 0 6 9"
|
|
fill="none"
|
|
className="translate-x-[6px] opacity-0 transition duration-200 group-hover:translate-x-0 group-hover:opacity-100"
|
|
>
|
|
<path
|
|
d="M1.5 1.5L4.5 4.5L1.5 7.5"
|
|
stroke="var(--accent-teal)"
|
|
strokeWidth="2"
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
/>
|
|
</svg>
|
|
</span>
|
|
<span className="mt-1 text-[12px] font-medium leading-normal text-[var(--text-secondary)] transition-colors group-hover:text-[var(--text-primary)]">
|
|
{p.description}
|
|
</span>
|
|
</span>
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
<Link
|
|
href="/kunden"
|
|
className="text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
Für wen?
|
|
</Link>
|
|
<Link
|
|
href="/ki-anbindung"
|
|
className="text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
KI-Brücke
|
|
</Link>
|
|
<Link
|
|
href="/preise"
|
|
className="text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
Preise
|
|
</Link>
|
|
<Link
|
|
href="/ueber-uns"
|
|
className="text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
Über uns
|
|
</Link>
|
|
<Link
|
|
href="/waitlist"
|
|
className="text-[16px] leading-[1.25] font-medium text-[var(--text-primary)] hover:opacity-70 transition-opacity"
|
|
>
|
|
Warteliste
|
|
</Link>
|
|
</nav>
|
|
|
|
{/* Desktop CTA */}
|
|
<div className="hidden lg:flex items-center gap-2">
|
|
<a
|
|
href={loginHref}
|
|
className="inline-flex items-center justify-center rounded-[var(--radius-button)] text-[14px] font-semibold text-[var(--text-primary)] hover:bg-[var(--bg-muted)] transition-colors"
|
|
style={{ padding: "10px 14px" }}
|
|
>
|
|
Login
|
|
</a>
|
|
<DemoButton size="sm" href="/waitlist">Auf die Warteliste</DemoButton>
|
|
</div>
|
|
|
|
{/* Mobile Hamburger */}
|
|
<button
|
|
className="lg:hidden flex flex-col justify-center items-center w-10 h-10 gap-[5px]"
|
|
onClick={() => setMobileOpen((v) => !v)}
|
|
aria-label="Menü öffnen"
|
|
>
|
|
<span
|
|
className={`block w-6 h-0.5 bg-[var(--text-primary)] transition-transform duration-300 origin-center ${
|
|
mobileOpen ? "rotate-45 translate-y-[6.5px]" : ""
|
|
}`}
|
|
/>
|
|
<span
|
|
className={`block w-6 h-0.5 bg-[var(--text-primary)] transition-opacity duration-300 ${
|
|
mobileOpen ? "opacity-0" : ""
|
|
}`}
|
|
/>
|
|
<span
|
|
className={`block w-6 h-0.5 bg-[var(--text-primary)] transition-transform duration-300 origin-center ${
|
|
mobileOpen ? "-rotate-45 -translate-y-[6.5px]" : ""
|
|
}`}
|
|
/>
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
{/* Mobile Menu Overlay */}
|
|
<div
|
|
className={`fixed inset-0 z-40 lg:hidden transition-opacity duration-300 ${
|
|
mobileOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
|
}`}
|
|
style={{ background: "rgba(0,0,0,0.3)" }}
|
|
onClick={() => setMobileOpen(false)}
|
|
/>
|
|
|
|
{/* Mobile Menu Drawer */}
|
|
<div
|
|
className={`fixed top-0 right-0 bottom-0 z-50 w-[85vw] max-w-sm bg-white shadow-2xl lg:hidden flex flex-col transition-transform duration-300 ${
|
|
mobileOpen ? "translate-x-0" : "translate-x-full"
|
|
}`}
|
|
>
|
|
{/* Drawer Header */}
|
|
<div
|
|
className="flex items-center justify-between px-6"
|
|
style={{ height: 80, borderBottom: "1px solid var(--border-light)" }}
|
|
>
|
|
<Link
|
|
href="/"
|
|
className="hover:opacity-80 transition-opacity"
|
|
onClick={() => setMobileOpen(false)}
|
|
>
|
|
<img src="/logo.svg" alt="HiveGrid" style={{ height: 36 }} />
|
|
</Link>
|
|
<button
|
|
onClick={() => setMobileOpen(false)}
|
|
className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-[var(--bg-muted)] transition-colors"
|
|
aria-label="Menü schließen"
|
|
>
|
|
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
<path
|
|
d="M2 2L16 16M16 2L2 16"
|
|
stroke="var(--text-primary)"
|
|
strokeWidth="2"
|
|
strokeLinecap="round"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
{/* Drawer Links */}
|
|
<nav className="flex-1 overflow-y-auto px-6 py-6 flex flex-col gap-1">
|
|
{/* Produkte Group */}
|
|
<p className="text-[11px] font-semibold uppercase tracking-widest text-[var(--text-muted)] mt-4 mb-2">
|
|
Lösungen
|
|
</p>
|
|
{siteConfig.produkte.map((p) => (
|
|
<Link
|
|
key={p.href}
|
|
href={p.href}
|
|
onClick={() => setMobileOpen(false)}
|
|
className="block px-3 py-2.5 rounded-lg text-[15px] font-medium text-[var(--text-primary)] hover:bg-[var(--bg-muted)] transition-colors"
|
|
>
|
|
{p.label}
|
|
</Link>
|
|
))}
|
|
|
|
{/* General Links */}
|
|
<p className="text-[11px] font-semibold uppercase tracking-widest text-[var(--text-muted)] mt-6 mb-2">
|
|
Seiten
|
|
</p>
|
|
{[
|
|
{ label: "Für wen?", href: "/kunden" },
|
|
{ label: "KI-Brücke", href: "/ki-anbindung" },
|
|
{ label: "Preise", href: "/preise" },
|
|
{ label: "Über uns", href: "/ueber-uns" },
|
|
{ label: "Unsere Mission", href: "/mission" },
|
|
{ label: "Warteliste", href: "/waitlist" },
|
|
].map((link) => (
|
|
<Link
|
|
key={link.href}
|
|
href={link.href}
|
|
onClick={() => setMobileOpen(false)}
|
|
className="block px-3 py-2.5 rounded-lg text-[15px] font-medium text-[var(--text-primary)] hover:bg-[var(--bg-muted)] transition-colors"
|
|
>
|
|
{link.label}
|
|
</Link>
|
|
))}
|
|
</nav>
|
|
|
|
{/* Drawer CTA */}
|
|
<div className="px-6 py-6 flex flex-col gap-3" style={{ borderTop: "1px solid var(--border-light)" }}>
|
|
<a
|
|
href={loginHref}
|
|
onClick={() => setMobileOpen(false)}
|
|
className="inline-flex w-full items-center justify-center rounded-[var(--radius-button)] text-[15px] font-semibold text-[var(--text-primary)] transition-colors"
|
|
style={{ padding: "12px 20px", background: "var(--bg-muted)" }}
|
|
>
|
|
Login
|
|
</a>
|
|
<DemoButton href="/waitlist" onClick={() => setMobileOpen(false)} className="w-full [&_.demo-btn]:w-full">Auf die Warteliste</DemoButton>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|