"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { motion, AnimatePresence, type Variants } from "framer-motion"; import { TrptkLogo } from "../icons/TrptkLogo"; import { MenuToggleButton } from "./MenuToggleButton"; import { ThemeToggleButton } from "./ThemeToggleButton"; import { SocialButtons } from "./SocialButtons"; import { CartButton } from "@/components/cart/CartButton"; import { useCart } from "@/components/cart/CartContext"; import { AccountButton } from "@/components/auth/AccountButton"; import { GlobalSearch } from "@/components/search/GlobalSearch"; const nav = [ { href: "/", label: "Home" }, { href: "/blog", label: "Blog" }, { href: "/about", label: "About" }, { href: "/artists", label: "Artists" }, { href: "/composers", label: "Composers" }, { href: "/releases", label: "Releases" }, ]; const overlayVariants = { open: { opacity: 1, pointerEvents: "auto" as const, transition: { type: "tween", ease: "easeInOut", duration: 0.1, }, }, closed: { opacity: 0, transition: { type: "tween", ease: "easeInOut", duration: 0.1, delay: 0.5, }, transitionEnd: { pointerEvents: "none" as const, }, }, } satisfies Variants; const panelVariants = { open: { opacity: 1, transition: { type: "tween", ease: "easeInOut", duration: 0.4, }, }, closed: { opacity: 0, }, exit: { opacity: 0, transition: { type: "tween", ease: "easeInOut", duration: 0.5, delay: 0.5, }, }, } satisfies Variants; const listVariants = { closed: { transition: { staggerChildren: 0.1, staggerDirection: -1, }, }, open: { transition: { delayChildren: 0.1, staggerChildren: 0.1, }, }, } satisfies Variants; const itemVariants = { closed: { opacity: 0, y: 8 }, open: { opacity: 1, y: 0, transition: { type: "tween", ease: "easeInOut", duration: 0.35 }, }, } satisfies Variants; export function Header() { const [open, setOpen] = useState(false); const [searchOpen, setSearchOpen] = useState(false); const { itemCount } = useCart(); useEffect(() => { if (open) { // Prevent scrolling on both html and body document.documentElement.style.overflow = "hidden"; document.body.style.overflow = "hidden"; // Prevent iOS Safari overscroll document.body.style.position = "fixed"; document.body.style.width = "100%"; } else { document.documentElement.style.overflow = ""; document.body.style.overflow = ""; document.body.style.position = ""; document.body.style.width = ""; } return () => { document.documentElement.style.overflow = ""; document.body.style.overflow = ""; document.body.style.position = ""; document.body.style.width = ""; }; }, [open]); useEffect(() => { const onKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(false); }; window.addEventListener("keydown", onKeyDown); return () => window.removeEventListener("keydown", onKeyDown); }, []); return ( <> {/* Main Menu */}