"use client"; import Link from "next/link"; import { useCallback, useEffect, useId, useRef, useState } from "react"; const primaryNav = [ { label: "Música", href: "#" }, { label: "Atualidade", href: "#" }, { label: "Cultura", href: "#" }, { label: "Lifestyle", href: "#" }, { label: "Entrevistas", href: "#" }, { label: "Girl Power", href: "#" }, { label: "Desporto", href: "#" }, { label: "Contactos", href: "#" }, ]; const secondaryNav = [ { label: "Opinião", href: "#" }, { label: "Programas", href: "#" }, { label: "Vídeo", href: "#" }, { label: "Podcasts", href: "#" }, { label: "Especiais", href: "#" }, { label: "Verificação de factos", href: "#" }, ]; function SearchIcon({ className }: { className?: string }) { return ( ); } function MenuIcon({ className }: { className?: string }) { return ( ); } function CloseIcon({ className }: { className?: string }) { return ( ); } function ChevronDown({ className }: { className?: string }) { return ( ); } /** * Euronews-style navigation: primary row + secondary topic row (desktop), * sticky with shadow when docked, mobile sheet menu. */ export function TvoneSiteNav() { const sentinelRef = useRef(null); const [navIsStuck, setNavIsStuck] = useState(false); const [menuOpen, setMenuOpen] = useState(false); const menuId = useId(); const closeMenu = useCallback(() => setMenuOpen(false), []); const toggleMenu = useCallback(() => setMenuOpen((o) => !o), []); useEffect(() => { const el = sentinelRef.current; if (!el) return; const sync = () => { const rect = el.getBoundingClientRect(); setNavIsStuck(rect.bottom < 0); }; sync(); window.addEventListener("scroll", sync, { passive: true }); window.addEventListener("resize", sync); return () => { window.removeEventListener("scroll", sync); window.removeEventListener("resize", sync); }; }, []); useEffect(() => { if (!menuOpen) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") closeMenu(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [menuOpen, closeMenu]); useEffect(() => { if (!menuOpen) return; const prev = document.body.style.overflow; document.body.style.overflow = "hidden"; return () => { document.body.style.overflow = prev; }; }, [menuOpen]); useEffect(() => { const onResize = () => { if (window.matchMedia("(min-width: 1024px)").matches) setMenuOpen(false); }; window.addEventListener("resize", onResize); return () => window.removeEventListener("resize", onResize); }, []); return ( <> {/* Row 1 — Euronews-style main bar */} {menuOpen ? : } tv tvone {primaryNav.map((item) => ( {item.label} ))} {/* Row 2 — secondary topics (desktop), Euronews-style strip */} {/* Tópicos {secondaryNav.map((item) => ( {item.label} ))} */} {/* Mobile: menu is fixed + height from content only (no full-screen empty panel). */} {menuOpen ? ( <> Secções {primaryNav.map((item) => ( {item.label} ))} > ) : null} > ); }
Secções