Chart page tabs (analysis, planets, matrix, details); square aspect matrix
CI / test (push) Successful in 40s
CI / build (push) Successful in 3m36s
CI / deploy (push) Skipped

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-17 10:32:10 +00:00
co-authored by Claude Opus 5.5
parent d2a24ca42d
commit afa113ceca
5 changed files with 203 additions and 86 deletions
+23 -6
View File
@@ -239,8 +239,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
} }
.aspect-grid th { color: var(--ink); font-weight: 400; font-size: 17px; background: var(--panel-2); } .aspect-grid th { color: var(--ink); font-weight: 400; font-size: 17px; background: var(--panel-2); }
.aspect-grid .grid-angle { font: 600 11px var(--font-body); color: var(--gold); letter-spacing: 0.3px; } .aspect-grid .grid-angle { font: 600 11px var(--font-body); color: var(--gold); letter-spacing: 0.3px; }
.aspect-grid td.void, .aspect-grid td.corner { border: 0; background: none; } .aspect-grid td.corner { border: 0; background: none; }
.aspect-grid tbody td:not(.void):hover { background: var(--panel-2); } .aspect-grid td.diag { background: var(--line); }
.aspect-grid tbody td:not(.diag):hover { background: var(--panel-2); }
.grid-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); }
.grid-legend .sym { font-size: 17px; }
.asp-conjunction { color: var(--gold); } .asp-conjunction { color: var(--gold); }
.asp-trine, .asp-sextile { color: var(--harmonic); } .asp-trine, .asp-sextile { color: var(--harmonic); }
.asp-square { color: var(--square); } .asp-square { color: var(--square); }
@@ -248,10 +251,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.details > summary { cursor: pointer; color: var(--gold); min-height: 44px; display: flex; align-items: center; } .details > summary { cursor: pointer; color: var(--gold); min-height: 44px; display: flex; align-items: center; }
.details[open] > summary { margin-bottom: 8px; } .details[open] > summary { margin-bottom: 8px; }
@media (max-width: 640px) { @media (max-width: 640px) {
.aspect-grid { font-size: 13px; } .aspect-grid { font-size: 12px; }
.aspect-grid td, .aspect-grid th { width: 23px; min-width: 23px; height: 23px; } .aspect-grid td, .aspect-grid th { width: 19px; min-width: 19px; height: 19px; }
.aspect-grid th { font-size: 14px; } .aspect-grid th { font-size: 13px; }
.aspect-grid .grid-angle { font-size: 9px; } .aspect-grid .grid-angle { font-size: 8px; letter-spacing: 0; }
.chart-tabs { padding: 4px 12px 16px; }
} }
.aspect-harmonic { color: var(--harmonic); } .aspect-harmonic { color: var(--harmonic); }
.aspect-tense { color: var(--tense); } .aspect-tense { color: var(--tense); }
@@ -302,3 +306,16 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
} }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Tabs */
.chart-tabs { padding-top: 8px; }
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 12px 16px; min-height: 44px;
color: var(--muted); font: 500 15px var(--font-body); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.tab:focus-visible, .tab-panel:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tab-panel { padding-top: 20px; }
@media (max-width: 640px) { .tab { padding: 12px 10px; font-size: 14px; } }
@@ -1,16 +1,19 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { BigThree, ChartTables } from "@/components/ChartTables"; import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
import { ChartSummary } from "@/components/ChartSummary"; import { ChartSummary } from "@/components/ChartSummary";
import { DetailedAnalysis } from "@/components/DetailedAnalysis"; import { DetailedAnalysis } from "@/components/DetailedAnalysis";
import { ChartWheel, WheelLegend } from "@/components/ChartWheel"; import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro"; import { Tabs } from "@/components/Tabs";
import { ASPECTS, ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server"; import { backendGet, requireMe } from "@/lib/server";
import type { Analysis, Chart, PublicConfig } from "@/lib/types"; import type { Analysis, Chart, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Képlet" }; export const metadata: Metadata = { title: "Képlet" };
const GRID_LEGEND = ["conjunction", "sextile", "square", "trine", "opposition"];
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
/** One saved chart: the wheel and the tables, read from the database (not recalculated). */ /** One saved chart: the wheel and the tables, read from the database (not recalculated). */
@@ -105,6 +108,14 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
</div> </div>
</section> </section>
<section className="card chart-tabs" aria-label="Elemzés és táblázatok">
<Tabs
label="Képlet részletei"
tabs={[
{
id: "elemzes",
label: "Elemzés",
content: (
<DetailedAnalysis <DetailedAnalysis
chartId={chart.id} chartId={chart.id}
initial={detailed} initial={detailed}
@@ -112,10 +123,31 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
isAdmin={me.user.roles.includes("admin")} isAdmin={me.user.roles.includes("admin")}
canPay={config?.mock_payments ?? false} canPay={config?.mock_payments ?? false}
/> />
),
<section className="card" aria-labelledby="positions"> },
<h2 id="positions">Pozíciók</h2> { id: "bolygok", label: "Bolygók", content: <PositionTables chart={chart} /> },
<ChartTables chart={chart} /> {
id: "matrix",
label: "Mátrix",
content: (
<div className="field" style={{ gap: 16 }}>
<AspectGrid chart={chart} />
<ul className="grid-legend" aria-label="Jelmagyarázat">
{GRID_LEGEND.map((k) => (
<li key={k}>
<span className={`sym asp asp-${k}`} aria-hidden="true">
{ASPECTS[k]?.glyph}
</span>{" "}
{ASPECTS[k]?.hu}
</li>
))}
</ul>
</div>
),
},
{ id: "reszletek", label: "Részletek", content: <AspectList chart={chart} /> },
]}
/>
</section> </section>
</main> </main>
); );
@@ -67,8 +67,8 @@ const GRID_ANGLES: [string, string][] = [
["midheaven", "MC"], ["midheaven", "MC"],
]; ];
/** The usual triangular aspect grid: only the aspect symbols, the values are in the details below. */ /** The aspect grid: a square matrix with the points on both sides, only the aspect symbols in it. */
function AspectGrid({ chart }: { chart: Chart }) { export function AspectGrid({ chart }: { chart: Chart }) {
const result = chart.chart; const result = chart.chart;
const present = new Set(result.points.map((p) => p.id)); const present = new Set(result.points.map((p) => p.id));
const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [ const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [
@@ -83,14 +83,11 @@ function AspectGrid({ chart }: { chart: Chart }) {
byPair.set(`${a.point1}|${a.point2}`, a); byPair.set(`${a.point1}|${a.point2}`, a);
byPair.set(`${a.point2}|${a.point1}`, a); byPair.set(`${a.point2}|${a.point1}`, a);
} }
const label = ([id, text]: [string, string]) => ( const label = ([id, text]: [string, string]) => (
<span className={text.length > 2 ? "sym" : "grid-angle"} aria-label={pointName(id)} role="img"> <span className={text.length > 2 ? "sym" : "grid-angle"} aria-label={pointName(id)} role="img">
{text} {text}
</span> </span>
); );
// Lower triangle with both headers: rows from the 2nd point, columns up to the last but one.
const cols = rows.slice(0, -1);
return ( return (
<div className="aspect-grid-wrap"> <div className="aspect-grid-wrap">
@@ -98,7 +95,7 @@ function AspectGrid({ chart }: { chart: Chart }) {
<thead> <thead>
<tr> <tr>
<td className="corner" /> <td className="corner" />
{cols.map((c) => ( {rows.map((c) => (
<th key={c[0]} scope="col" title={pointName(c[0])}> <th key={c[0]} scope="col" title={pointName(c[0])}>
{label(c)} {label(c)}
</th> </th>
@@ -106,18 +103,18 @@ function AspectGrid({ chart }: { chart: Chart }) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{rows.slice(1).map((row, r) => { {rows.map((row) => {
const [id] = row; const [id] = row;
return ( return (
<tr key={id}> <tr key={id}>
<th scope="row" title={pointName(id)}> <th scope="row" title={pointName(id)}>
{label(row)} {label(row)}
</th> </th>
{cols.map(([other], j) => { {rows.map(([other]) => {
if (j > r) return <td key={other} className="void" />; if (other === id) return <td key={other} className="diag" />;
const a = byPair.get(`${id}|${other}`); const a = byPair.get(`${id}|${other}`);
const info = a ? ASPECTS[a.aspect] : undefined; const info = a ? ASPECTS[a.aspect] : undefined;
const text = a ? `${pointName(other)} ${info?.hu ?? a.aspect} ${pointName(id)}` : undefined; const text = a ? `${pointName(id)} ${info?.hu ?? a.aspect} ${pointName(other)}` : undefined;
return ( return (
<td key={other} title={text}> <td key={other} title={text}>
{a && ( {a && (
@@ -137,15 +134,14 @@ function AspectGrid({ chart }: { chart: Chart }) {
); );
} }
/** Positions, angles, house cusps and aspects of a natal chart. */ /** Positions, angles and house cusps of a natal chart. */
export function ChartTables({ chart }: { chart: Chart }) { export function PositionTables({ chart }: { chart: Chart }) {
const result = chart.chart; const result = chart.chart;
const timeKnown = chart.highlights.time_known; const timeKnown = chart.highlights.time_known;
const angles = ANGLES.map(([key, label]) => [label, result.angles?.[key]] as const).filter( const angles = ANGLES.map(([key, label]) => [label, result.angles?.[key]] as const).filter(
(a): a is readonly [string, Position] => typeof a[1] === "object" && a[1] !== null, (a): a is readonly [string, Position] => typeof a[1] === "object" && a[1] !== null,
); );
const fortune = result.lots?.fortune; const fortune = result.lots?.fortune;
const aspects = [...(result.aspects ?? [])].sort((a, b) => a.orb - b.orb);
return ( return (
<div className="field" style={{ gap: 24 }}> <div className="field" style={{ gap: 24 }}>
@@ -230,12 +226,21 @@ export function ChartTables({ chart }: { chart: Chart }) {
</div> </div>
)} )}
</div> </div>
{aspects.length > 0 && ( {!timeKnown && (
<div className="field" style={{ gap: 12 }}> <p className="hint">
<h3>Fényszögek</h3> Születési idő nélkül a házak, a tengelyek és az Aszcendens nem számolhatók; a Hold helyzete a nap folyamán akár
<AspectGrid chart={chart} /> jegyet is válthat, ezért közelítő.
<details className="details"> </p>
<summary>Részletek: orbisz, közeledő vagy távolodó</summary> )}
</div>
);
}
/** Every aspect with its orb and whether it is applying, closest first. */
export function AspectList({ chart }: { chart: Chart }) {
const aspects = [...(chart.chart.aspects ?? [])].sort((a, b) => a.orb - b.orb);
if (aspects.length === 0) return <p className="muted">Nincs fényszög.</p>;
return (
<div className="table-wrap"> <div className="table-wrap">
<table> <table>
<thead> <thead>
@@ -278,15 +283,5 @@ export function ChartTables({ chart }: { chart: Chart }) {
</tbody> </tbody>
</table> </table>
</div> </div>
</details>
</div>
)}
{!timeKnown && (
<p className="hint">
Születési idő nélkül a házak, a tengelyek és az Aszcendens nem számolhatók; a Hold helyzete a nap folyamán akár
jegyet is válthat, ezért közelítő.
</p>
)}
</div>
); );
} }
@@ -78,7 +78,7 @@ export function DetailedAnalysis({
if (analysis?.status === "done" && analysis.content) { if (analysis?.status === "done" && analysis.content) {
return ( return (
<section className="card analysis-card" aria-label="Részletes elemzés"> <section className="analysis-card" aria-label="Részletes elemzés">
<span className="eyebrow">Részletes elemzés</span> <span className="eyebrow">Részletes elemzés</span>
<AnalysisView content={analysis.content} /> <AnalysisView content={analysis.content} />
</section> </section>
@@ -87,7 +87,7 @@ export function DetailedAnalysis({
if (waiting) { if (waiting) {
return ( return (
<section className="card analysis-card" aria-label="Részletes elemzés" aria-busy="true"> <section className="analysis-card" aria-label="Részletes elemzés" aria-busy="true">
<span className="eyebrow">Részletes elemzés</span> <span className="eyebrow">Részletes elemzés</span>
<AnalysisLoading <AnalysisLoading
title="Készül az elemzésed" title="Készül az elemzésed"
@@ -98,7 +98,7 @@ export function DetailedAnalysis({
} }
return ( return (
<section className="card analysis-card" aria-labelledby="detailed-title"> <section className="analysis-card" aria-labelledby="detailed-title">
<span className="eyebrow">Részletes elemzés</span> <span className="eyebrow">Részletes elemzés</span>
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2> <h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
<p className="muted"> <p className="muted">
+73
View File
@@ -0,0 +1,73 @@
"use client";
import { type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from "react";
export type Tab = { id: string; label: string; content: ReactNode };
/**
* Tabs with the chosen one kept in the URL hash (#matrix), so a reload or a
* shared link opens the same tab. Hidden panels stay mounted: a running
* analysis keeps polling while another tab is open.
*/
export function Tabs({ tabs, label }: { tabs: Tab[]; label: string }) {
const [active, setActive] = useState(tabs[0]?.id);
const buttons = useRef<(HTMLButtonElement | null)[]>([]);
useEffect(() => {
const fromHash = window.location.hash.slice(1);
if (tabs.some((t) => t.id === fromHash)) setActive(fromHash);
}, [tabs]);
function choose(id: string) {
setActive(id);
history.replaceState(null, "", `#${id}`);
}
function onKey(e: KeyboardEvent, i: number) {
const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
const to = e.key === "Home" ? 0 : e.key === "End" ? tabs.length - 1 : step ? (i + step + tabs.length) % tabs.length : -1;
if (to < 0) return;
e.preventDefault();
choose(tabs[to].id);
buttons.current[to]?.focus();
}
return (
<div className="tabs">
<div className="tab-list" role="tablist" aria-label={label}>
{tabs.map((t, i) => (
<button
key={t.id}
ref={(el) => {
buttons.current[i] = el;
}}
type="button"
role="tab"
id={`tab-${t.id}`}
aria-controls={`panel-${t.id}`}
aria-selected={active === t.id}
tabIndex={active === t.id ? 0 : -1}
className="tab"
onClick={() => choose(t.id)}
onKeyDown={(e) => onKey(e, i)}
>
{t.label}
</button>
))}
</div>
{tabs.map((t) => (
<div
key={t.id}
role="tabpanel"
id={`panel-${t.id}`}
aria-labelledby={`tab-${t.id}`}
hidden={active !== t.id}
className="tab-panel"
tabIndex={0}
>
{t.content}
</div>
))}
</div>
);
}