2026-06-14 15:36:44 +02:00
|
|
|
'use client'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
import { usePathname, useRouter } from 'next/navigation'
|
2026-06-14 20:08:03 +02:00
|
|
|
import { useState, useEffect } from 'react'
|
2026-06-14 15:36:44 +02:00
|
|
|
|
|
|
|
|
const NAV_LINKS = [
|
|
|
|
|
{ href: '/', label: 'Home' },
|
|
|
|
|
{ href: '/groups', label: 'Groups' },
|
|
|
|
|
{ href: '/stats', label: 'Statistics' },
|
|
|
|
|
{ href: '/history', label: 'History' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export function Nav() {
|
|
|
|
|
const pathname = usePathname()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const [q, setQ] = useState('')
|
2026-06-14 20:08:03 +02:00
|
|
|
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])
|
2026-06-14 15:36:44 +02:00
|
|
|
|
|
|
|
|
const handleSearch = (e: React.FormEvent) => {
|
|
|
|
|
e.preventDefault()
|
2026-06-14 20:08:03 +02:00
|
|
|
if (q.trim()) {
|
|
|
|
|
router.push(`/search?q=${encodeURIComponent(q.trim())}`)
|
|
|
|
|
setOpen(false)
|
|
|
|
|
setQ('')
|
|
|
|
|
}
|
2026-06-14 15:36:44 +02:00
|
|
|
}
|
|
|
|
|
|
2026-06-14 20:08:03 +02:00
|
|
|
const isActive = (href: string) =>
|
|
|
|
|
href === '/' ? pathname === '/' : pathname.startsWith(href)
|
|
|
|
|
|
2026-06-14 15:36:44 +02:00
|
|
|
return (
|
2026-06-14 20:08:03 +02:00
|
|
|
<>
|
|
|
|
|
<nav
|
2026-06-14 21:46:33 +02:00
|
|
|
className="fixed top-0 left-0 right-0 z-50 h-[60px]"
|
2026-06-14 20:08:03 +02:00
|
|
|
style={{ background: 'rgba(4,13,8,0.97)', backdropFilter: 'blur(18px)', borderBottom: '1px solid rgba(34,197,94,0.18)' }}
|
|
|
|
|
>
|
2026-06-14 21:46:33 +02:00
|
|
|
<div className="max-w-[1200px] mx-auto px-7 h-full flex items-center">
|
2026-06-14 20:08:03 +02:00
|
|
|
{/* Logo */}
|
|
|
|
|
<Link href="/" className="flex items-center gap-2.5 flex-shrink-0 cursor-pointer select-none">
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img src="/favicon.svg" style={{ height: '36px', width: 'auto' }} alt="" />
|
|
|
|
|
<span className="font-['Bebas_Neue'] text-lg tracking-[3px] text-[#22c55e] whitespace-nowrap">WORLD CUP</span>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{/* Desktop links */}
|
|
|
|
|
<div className="hidden md:flex gap-0.5 flex-1 min-w-0 ml-5">
|
|
|
|
|
{NAV_LINKS.map(({ href, label }) => (
|
2026-06-14 15:36:44 +02:00
|
|
|
<Link key={href} href={href}
|
2026-06-14 20:08:03 +02:00
|
|
|
className={`px-3.5 py-1.5 rounded-lg text-[13px] font-medium whitespace-nowrap transition-colors
|
|
|
|
|
${isActive(href) ? 'bg-[rgba(34,197,94,0.12)] text-[#22c55e]' : 'text-[#4a7a55] hover:text-[#6abf7a]'}`}>
|
2026-06-14 15:36:44 +02:00
|
|
|
{label}
|
|
|
|
|
</Link>
|
2026-06-14 20:08:03 +02:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Desktop search */}
|
|
|
|
|
<form onSubmit={handleSearch} className="relative flex-shrink-0 ml-auto hidden md:block">
|
|
|
|
|
<input
|
|
|
|
|
type="text" value={q} onChange={e => setQ(e.target.value)}
|
|
|
|
|
placeholder="Search…"
|
|
|
|
|
className="w-44 pl-8 pr-3.5 py-1.5 rounded-[20px] text-[13px] text-[#dff5e8] outline-none"
|
|
|
|
|
style={{ background: 'rgba(34,197,94,0.06)', border: '1px solid rgba(34,197,94,0.18)' }}
|
|
|
|
|
/>
|
|
|
|
|
<svg className="absolute left-2.5 top-1/2 -translate-y-1/2 opacity-30 pointer-events-none" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#dff5e8" strokeWidth="2.5">
|
|
|
|
|
<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
|
|
|
</svg>
|
|
|
|
|
</form>
|
2026-06-14 15:36:44 +02:00
|
|
|
|
2026-06-14 20:08:03 +02:00
|
|
|
{/* Hamburger */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setOpen(o => !o)}
|
|
|
|
|
className="ml-auto md:hidden flex flex-col justify-center items-center w-9 h-9 gap-[5px] rounded-lg transition-colors"
|
|
|
|
|
style={{ background: open ? 'rgba(34,197,94,0.1)' : 'transparent' }}
|
|
|
|
|
aria-label="Menu"
|
|
|
|
|
>
|
|
|
|
|
<span className={`block w-5 h-[2px] bg-[#22c55e] rounded-full transition-all origin-center ${open ? 'rotate-45 translate-y-[7px]' : ''}`} />
|
|
|
|
|
<span className={`block w-5 h-[2px] bg-[#22c55e] rounded-full transition-all ${open ? 'opacity-0' : ''}`} />
|
|
|
|
|
<span className={`block w-5 h-[2px] bg-[#22c55e] rounded-full transition-all origin-center ${open ? '-rotate-45 -translate-y-[7px]' : ''}`} />
|
|
|
|
|
</button>
|
2026-06-14 21:46:33 +02:00
|
|
|
</div>
|
2026-06-14 20:08:03 +02:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
{/* Mobile menu overlay */}
|
|
|
|
|
{open && (
|
|
|
|
|
<div
|
|
|
|
|
className="fixed inset-0 z-40 md:hidden"
|
|
|
|
|
style={{ background: 'rgba(4,13,8,0.6)', backdropFilter: 'blur(4px)', top: '60px' }}
|
|
|
|
|
onClick={() => setOpen(false)}
|
2026-06-14 15:36:44 +02:00
|
|
|
/>
|
2026-06-14 20:08:03 +02:00
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Mobile menu panel */}
|
|
|
|
|
<div
|
|
|
|
|
className={`fixed left-0 right-0 z-40 md:hidden transition-all duration-200 ${open ? 'top-[60px] opacity-100' : 'top-[48px] opacity-0 pointer-events-none'}`}
|
|
|
|
|
style={{ background: 'rgba(4,13,8,0.98)', borderBottom: '1px solid rgba(34,197,94,0.18)' }}
|
|
|
|
|
>
|
|
|
|
|
<div className="px-5 py-4 flex flex-col gap-1">
|
|
|
|
|
{NAV_LINKS.map(({ href, label }) => (
|
|
|
|
|
<Link key={href} href={href}
|
|
|
|
|
className={`px-4 py-3 rounded-xl text-[15px] font-medium transition-colors
|
|
|
|
|
${isActive(href) ? 'bg-[rgba(34,197,94,0.12)] text-[#22c55e]' : 'text-[#6abf7a] hover:bg-[rgba(34,197,94,0.06)]'}`}>
|
|
|
|
|
{label}
|
|
|
|
|
</Link>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
<form onSubmit={handleSearch} className="relative mt-3">
|
|
|
|
|
<input
|
|
|
|
|
type="text" value={q} onChange={e => 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)' }}
|
|
|
|
|
/>
|
|
|
|
|
<svg className="absolute left-3 top-1/2 -translate-y-1/2 opacity-30 pointer-events-none" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#dff5e8" strokeWidth="2.5">
|
|
|
|
|
<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
|
|
|
</svg>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
2026-06-14 15:36:44 +02:00
|
|
|
)
|
|
|
|
|
}
|