Header: ☰ menu where the links do not fit; famous people in the menus
CI / test (push) Successful in 1m59s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Logged out below 1240px and logged in below 1380px the link rows give way
  to a ☰ menu (with the "Ingyenes" group when logged out); on phones the
  account button is an icon and the package pill makes room.
- "Híres emberek" in the free links of the header, among the free cards
  of the home page and in the menu of logged-in users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-22 17:14:50 +00:00
co-authored by Claude Opus 5.5
parent 2997a06474
commit 26c5bb2746
6 changed files with 173 additions and 3 deletions
@@ -0,0 +1,83 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useEffect, useId, useRef, useState } from "react";
export interface MenuSection {
/** A small heading above the group (e.g. "Ingyenes"). */
title?: string;
links: { href: string; label: string }[];
}
/**
* The menu behind the ☰ button on narrow screens (the header's link rows are
* hidden there, see globals.css). Closes on a click outside, Escape, or
* moving to another page. `className` sets the width from which it shows.
*/
export function MobileMenu({ sections, className }: { sections: MenuSection[]; className: string }) {
const [open, setOpen] = useState(false);
const box = useRef<HTMLDivElement>(null);
const button = useRef<HTMLButtonElement>(null);
const panelId = useId();
const pathname = usePathname();
useEffect(() => setOpen(false), [pathname]);
useEffect(() => {
if (!open) return;
const outside = (e: PointerEvent) => {
if (box.current && !box.current.contains(e.target as Node)) setOpen(false);
};
const escape = (e: KeyboardEvent) => {
if (e.key === "Escape") {
setOpen(false);
button.current?.focus();
}
};
document.addEventListener("pointerdown", outside);
document.addEventListener("keydown", escape);
return () => {
document.removeEventListener("pointerdown", outside);
document.removeEventListener("keydown", escape);
};
}, [open]);
const current = (href: string) => !href.includes("#") && pathname.startsWith(href);
return (
<div className={`mobile-menu ${className}`} ref={box}>
<button
ref={button}
type="button"
className="mobile-menu-button"
aria-expanded={open}
aria-controls={panelId}
aria-label={open ? "Menü bezárása" : "Menü"}
onClick={() => setOpen((o) => !o)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
{open ? <path d="M6 6l12 12M18 6L6 18" /> : <path d="M4 7h16M4 12h16M4 17h16" />}
</svg>
</button>
{open && (
<nav id={panelId} className="mobile-menu-panel" aria-label="Menü">
{sections.map((s, i) => (
<div key={i} className="mobile-menu-group">
{s.title && <span className="lp-free-label">{s.title}</span>}
{s.links.map((l) => (
<Link
key={l.href}
href={l.href}
aria-current={current(l.href) ? "page" : undefined}
onClick={() => setOpen(false)}
>
{l.label}
</Link>
))}
</div>
))}
</nav>
)}
</div>
);
}