App header: gold marks, a "Felfedezés" dropdown, the Moon today
CI / test (push) Successful in 2m28s
CI / build (push) Skipped
CI / deploy (push) Skipped

- Menu items with gold astrological marks (☉ ☽ ☌, card, box); the free
  pages (signs, famous people, moon calendar, retrogrades) in one
  "Felfedezés" dropdown with a line about each, opened by a click
- A starry header band with a gold edge; the current item has a glowing
  gold underline
- "Ma: Hold a ♉ Bikában" with the Moon's phase drawn as it is lit, to the
  moon calendar (narrower screens: the phase and the glyph)
- The ☰ menu grouped: the Moon today, Saját, Felfedezés · ingyenes as
  tiles, Csomagok with the package; it covers the page now
- Laptops (1440px) keep the row on one line

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-24 09:17:48 +00:00
co-authored by Claude Opus 5.5
parent 12d5d6a9d1
commit 227e8b5b80
7 changed files with 413 additions and 35 deletions
+30 -12
View File
@@ -4,10 +4,14 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import { useEffect, useId, useRef, useState } from "react";
import { NavIcon, type NavIconName } from "./NavIcon";
export interface MenuSection {
/** A small heading above the group (e.g. "Ingyenes"). */
title?: string;
links: { href: string; label: string }[];
/** Two columns of tiles instead of a list. */
grid?: boolean;
links: { href: string; label: string; icon?: NavIconName; note?: string }[];
}
/**
@@ -15,7 +19,16 @@ export interface MenuSection {
* 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 }) {
export function MobileMenu({
sections,
className,
lead,
}: {
sections: MenuSection[];
className: string;
/** Shown first in the panel (the Moon today). */
lead?: React.ReactNode;
}) {
const [open, setOpen] = useState(false);
const box = useRef<HTMLDivElement>(null);
const button = useRef<HTMLButtonElement>(null);
@@ -61,19 +74,24 @@ export function MobileMenu({ sections, className }: { sections: MenuSection[]; c
</button>
{open && (
<nav id={panelId} className="mobile-menu-panel" aria-label="Menü">
{lead}
{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 className={s.grid ? "mobile-menu-grid" : "mobile-menu-list"}>
{s.links.map((l) => (
<Link
key={l.href}
href={l.href}
aria-current={current(l.href) ? "page" : undefined}
onClick={() => setOpen(false)}
>
{l.icon && <NavIcon name={l.icon} />}
<span className="mobile-menu-label">{l.label}</span>
{l.note && <span className="mobile-menu-note">{l.note}</span>}
</Link>
))}
</div>
</div>
))}
</nav>
@@ -0,0 +1,58 @@
import Link from "next/link";
import { SIGNS } from "@/lib/astro";
import { SIGN_IN, withArticle } from "@/lib/skyText";
import type { SkyNow } from "@/lib/types";
/** The Moon as it is lit now: the lit part on the right while waxing, on the left while waning. */
export function MoonPhaseIcon({
illumination,
waxing,
}: {
illumination: number;
waxing: boolean;
}) {
const r = 8.5;
const k = Math.min(1, Math.max(0, illumination));
const rx = Math.abs(1 - 2 * k) * r;
// The outer edge on the lit side, then the terminator back.
const outer = waxing ? 1 : 0;
const terminator = waxing ? (k > 0.5 ? 1 : 0) : k > 0.5 ? 0 : 1;
const d = `M12 ${12 - r}A${r} ${r} 0 0 ${outer} 12 ${12 + r}A${rx} ${r} 0 0 ${terminator} 12 ${12 - r}Z`;
return (
<svg className="moon-phase-icon" viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r={r} className="moon-dark" />
<path d={d} className="moon-lit" />
</svg>
);
}
/**
* "Ma: Hold a ♉ Bikában" in the header (the moon calendar behind it). Narrow
* screens show the phase and the sign's glyph only.
*/
export function MoonChip({ sky }: { sky: SkyNow }) {
const moon = sky.moon;
const sign = moon.position.sign;
const where = withArticle(SIGN_IN[sign] ?? sign);
return (
<Link
href="/holdnaptar"
className="moon-chip"
aria-label={`Ma a Hold ${where} jár: holdnaptár`}
>
<MoonPhaseIcon illumination={moon.illumination} waxing={moon.waxing} />
<span className="moon-chip-text" aria-hidden="true">
Ma: Hold {where.split(" ")[0]}{" "}
</span>
<span className="moon-chip-glyph sym" aria-hidden="true">
{SIGNS[sign]?.glyph}
{"︎"}
</span>
<span className="moon-chip-text" aria-hidden="true">
{" "}
{SIGN_IN[sign]}
</span>
</Link>
);
}
@@ -0,0 +1,73 @@
// Small gold marks before the menu items: astrological glyphs where one fits,
// otherwise a line drawing.
export type NavIconName =
| "chart"
| "persons"
| "compare"
| "tarot"
| "explore"
| "signs"
| "famous"
| "moon"
| "retro"
| "packages"
| "admin";
const GLYPHS: Partial<Record<NavIconName, string>> = {
chart: "☉",
persons: "☽",
compare: "☌",
explore: "✧",
signs: "♈",
retro: "☿",
};
export function NavIcon({ name }: { name: NavIconName }) {
const glyph = GLYPHS[name];
if (glyph) {
return (
<span className="nav-icon sym" aria-hidden="true">
{glyph}
{"︎"}
</span>
);
}
return (
<svg className="nav-icon" viewBox="0 0 24 24" aria-hidden="true">
{name === "tarot" && (
<>
<rect x="5" y="3" width="14" height="18" rx="2.2" />
<path
d="M12 8l1.2 2.8 2.8 1.2-2.8 1.2L12 16l-1.2-2.8L8 12l2.8-1.2z"
className="nav-icon-fill"
/>
</>
)}
{name === "famous" && (
<path d="M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6L12 16.6 6.6 19.5l1.2-6L3.3 9.3l6.1-.7z" />
)}
{name === "moon" && (
<>
<circle cx="12" cy="12" r="8.5" />
<path
d="M12 3.5a8.5 8.5 0 0 1 0 17a5 8.5 0 0 0 0-17z"
className="nav-icon-fill"
/>
</>
)}
{name === "packages" && (
<>
<path d="M12 2.5l8.5 4.7v9.6L12 21.5l-8.5-4.7V7.2z" />
<path d="M3.5 7.2L12 12l8.5-4.8M12 12v9.5" />
</>
)}
{name === "admin" && (
<>
<circle cx="12" cy="12" r="3" />
<path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1" />
</>
)}
</svg>
);
}
+126 -6
View File
@@ -2,16 +2,136 @@
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useEffect, useId, useRef, useState } from "react";
export function NavLinks({ links }: { links: { href: string; label: string }[] }) {
import { NavIcon, type NavIconName } from "./NavIcon";
export interface NavItem {
href: string;
label: string;
icon: NavIconName;
/** One line under the label in a dropdown. */
note?: string;
}
export interface NavGroup {
label: string;
icon: NavIconName;
/** The dropdown's small heading. */
title: string;
items: NavItem[];
}
const isGroup = (e: NavItem | NavGroup): e is NavGroup => "items" in e;
/**
* The app's menu row: items with a gold mark, and a group (the free pages)
* that opens on a click as a dropdown. Closes on a click outside, Escape or
* moving to another page.
*/
export function NavLinks({ entries }: { entries: (NavItem | NavGroup)[] }) {
const pathname = usePathname();
const here = (href: string) => pathname.startsWith(href);
return (
<nav className="nav app-nav" aria-label="Fő navigáció">
{links.map((l) => (
<Link key={l.href} href={l.href} aria-current={pathname.startsWith(l.href) ? "page" : undefined}>
{l.label}
</Link>
))}
{entries.map((e) =>
isGroup(e) ? (
<Dropdown
key={e.label}
group={e}
active={e.items.some((i) => here(i.href))}
here={here}
/>
) : (
<Link
key={e.href}
href={e.href}
aria-current={here(e.href) ? "page" : undefined}
>
<NavIcon name={e.icon} />
{e.label}
</Link>
),
)}
</nav>
);
}
function Dropdown({
group,
active,
here,
}: {
group: NavGroup;
active: boolean;
here: (href: string) => boolean;
}) {
const [open, setOpen] = useState(false);
const box = useRef<HTMLDivElement>(null);
const button = useRef<HTMLButtonElement>(null);
const id = 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]);
return (
<div className="nav-group" ref={box}>
<button
ref={button}
type="button"
className={active ? "nav-group-button is-active" : "nav-group-button"}
aria-expanded={open}
aria-controls={id}
onClick={() => setOpen((o) => !o)}
>
<NavIcon name={group.icon} />
{group.label}
<svg
viewBox="0 0 24 24"
aria-hidden="true"
className="nav-group-chevron"
>
<path d="M6 9l6 6 6-6" />
</svg>
</button>
{open && (
<div id={id} className="nav-dropdown">
<span className="nav-dropdown-title">{group.title}</span>
{group.items.map((i) => (
<Link
key={i.href}
href={i.href}
className="nav-dropdown-item"
aria-current={here(i.href) ? "page" : undefined}
>
<NavIcon name={i.icon} />
<span className="nav-dropdown-text">
<span>{i.label}</span>
{i.note && <span className="hint">{i.note}</span>}
</span>
</Link>
))}
</div>
)}
</div>
);
}
+49 -16
View File
@@ -1,9 +1,10 @@
import Link from "next/link";
import type { Me } from "@/lib/types";
import type { Me, SkyNow } from "@/lib/types";
import { MobileMenu } from "./MobileMenu";
import { NavLinks } from "./NavLinks";
import { MoonChip } from "./MoonChip";
import { type NavGroup, type NavItem, NavLinks } from "./NavLinks";
import { UserMenu } from "./UserMenu";
/** The mark: the orbit, the thread (an S, with the crossbar an f) and a star on the rim. */
@@ -128,23 +129,47 @@ function PackageBadge({ me }: { me: Me }) {
);
}
export function SiteHeader({ me }: { me: Me }) {
const links = [
{ href: "/keplet", label: "Képletem" },
{ href: "/szemelyek", label: "Személyek" },
{ href: "/osszevetesek", label: "Összevetések" },
{ href: "/kartyajoslas", label: "Kártyajóslás" },
{ href: "/csillagjegyek", label: "Csillagjegyek" },
{ href: "/hires-emberek", label: "Híres emberek" },
{ href: "/csomagok", label: "Csomagok" },
/** The free pages: in the menu row one dropdown, in the ☰ menu a group of tiles. */
const EXPLORE: NavItem[] = [
{ href: "/csillagjegyek", label: "Csillagjegyek", icon: "signs", note: "A tizenkét jegy jellemzése" },
{ href: "/hires-emberek", label: "Híres emberek", icon: "famous", note: "Ismert emberek képlete és elemzése" },
{ href: "/holdnaptar", label: "Holdnaptár", icon: "moon", note: "Holdfázisok, fogyatkozások, holdjegyek" },
{ href: "/retrograd", label: "Retrográd bolygók", icon: "retro", note: "Mikor retrográd a Merkúr és a többi" },
];
/**
* The header of the logged-in app: the menu with gold marks (the free pages
* in one "Felfedezés" dropdown), the Moon today, the package and the account.
* Below 1380px the menu moves behind ☰, grouped.
*/
export function SiteHeader({ me, sky }: { me: Me; sky?: SkyNow | null }) {
const own: NavItem[] = [
{ href: "/keplet", label: "Képletem", icon: "chart" },
{ href: "/szemelyek", label: "Személyek", icon: "persons" },
{ href: "/osszevetesek", label: "Összevetések", icon: "compare" },
{ href: "/kartyajoslas", label: "Kártyajóslás", icon: "tarot" },
];
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
else if (me.user.roles.includes("creator")) links.push({ href: "/admin/hires-emberek", label: "Szerző" });
const packages: NavItem = { href: "/csomagok", label: "Csomagok", icon: "packages" };
const team: NavItem[] = me.user.roles.includes("admin")
? [{ href: "/admin", label: "Admin", icon: "admin" }]
: me.user.roles.includes("creator")
? [{ href: "/admin/hires-emberek", label: "Szerző", icon: "admin" }]
: [];
const entries: (NavItem | NavGroup)[] = [
...own,
{ label: "Felfedezés", icon: "explore", title: "Ingyenes, mindenkinek", items: EXPLORE },
packages,
...team,
];
const { natal, synastry } = me.analyses_left;
const left = natal + synastry;
const packageNote = me.package ? `${me.package.name} · ${left} elemzés` : left > 0 ? `${left} elemzés` : undefined;
return (
<header className="site-header">
<header className="site-header app-header">
<Logo />
<NavLinks links={links} />
<NavLinks entries={entries} />
<div className="who">
{sky && <MoonChip sky={sky} />}
<PackageBadge me={me} />
<UserMenu
name={me.user.display_name || me.user.email}
@@ -152,7 +177,15 @@ export function SiteHeader({ me }: { me: Me }) {
replies={me.feedback_replies_unseen ?? 0}
/>
</div>
<MobileMenu className="mobile-menu-app" sections={[{ links }]} />
<MobileMenu
className="mobile-menu-app"
lead={sky ? <MoonChip sky={sky} /> : undefined}
sections={[
{ title: "Saját", links: own },
{ title: "Felfedezés · ingyenes", grid: true, links: EXPLORE.map(({ note: _note, ...l }) => l) },
{ links: [{ ...packages, note: packageNote }, ...team] },
]}
/>
</header>
);
}