diff --git a/components/nav.tsx b/components/nav.tsx index 6b38f4b..89f0c78 100644 --- a/components/nav.tsx +++ b/components/nav.tsx @@ -1,12 +1,7 @@ 'use client' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' -import { useState } from 'react' - -const WC_TROPHY = ( - // eslint-disable-next-line @next/next/no-img-element - -) +import { useState, useEffect } from 'react' const NAV_LINKS = [ { href: '/', label: 'Home' }, @@ -19,44 +14,115 @@ export function Nav() { const pathname = usePathname() const router = useRouter() const [q, setQ] = useState('') + const [open, setOpen] = useState(false) + + // Close menu on route change + useEffect(() => { setOpen(false) }, [pathname]) + + // Lock body scroll when menu open + useEffect(() => { + document.body.style.overflow = open ? 'hidden' : '' + return () => { document.body.style.overflow = '' } + }, [open]) const handleSearch = (e: React.FormEvent) => { e.preventDefault() - if (q.trim()) router.push(`/search?q=${encodeURIComponent(q.trim())}`) + if (q.trim()) { + router.push(`/search?q=${encodeURIComponent(q.trim())}`) + setOpen(false) + setQ('') + } } - return ( - + + {/* Mobile menu overlay */} + {open && ( +
setOpen(false)} /> - - - - - + )} + + {/* Mobile menu panel */} +
+
+ {NAV_LINKS.map(({ href, label }) => ( + + {label} + + ))} + +
+ setQ(e.target.value)} + placeholder="Search players, teams, tournaments…" + className="w-full pl-9 pr-4 py-3 rounded-xl text-[14px] text-[#dff5e8] outline-none" + style={{ background: 'rgba(34,197,94,0.06)', border: '1px solid rgba(34,197,94,0.18)' }} + /> + + + +
+
+
+ ) }