Chart page tabs (analysis, planets, matrix, details); square aspect matrix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -67,8 +67,8 @@ const GRID_ANGLES: [string, string][] = [
|
||||
["midheaven", "MC"],
|
||||
];
|
||||
|
||||
/** The usual triangular aspect grid: only the aspect symbols, the values are in the details below. */
|
||||
function AspectGrid({ chart }: { chart: Chart }) {
|
||||
/** The aspect grid: a square matrix with the points on both sides, only the aspect symbols in it. */
|
||||
export function AspectGrid({ chart }: { chart: Chart }) {
|
||||
const result = chart.chart;
|
||||
const present = new Set(result.points.map((p) => p.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.point2}|${a.point1}`, a);
|
||||
}
|
||||
|
||||
const label = ([id, text]: [string, string]) => (
|
||||
<span className={text.length > 2 ? "sym" : "grid-angle"} aria-label={pointName(id)} role="img">
|
||||
{text}
|
||||
</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 (
|
||||
<div className="aspect-grid-wrap">
|
||||
@@ -98,7 +95,7 @@ function AspectGrid({ chart }: { chart: Chart }) {
|
||||
<thead>
|
||||
<tr>
|
||||
<td className="corner" />
|
||||
{cols.map((c) => (
|
||||
{rows.map((c) => (
|
||||
<th key={c[0]} scope="col" title={pointName(c[0])}>
|
||||
{label(c)}
|
||||
</th>
|
||||
@@ -106,18 +103,18 @@ function AspectGrid({ chart }: { chart: Chart }) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.slice(1).map((row, r) => {
|
||||
{rows.map((row) => {
|
||||
const [id] = row;
|
||||
return (
|
||||
<tr key={id}>
|
||||
<th scope="row" title={pointName(id)}>
|
||||
{label(row)}
|
||||
</th>
|
||||
{cols.map(([other], j) => {
|
||||
if (j > r) return <td key={other} className="void" />;
|
||||
{rows.map(([other]) => {
|
||||
if (other === id) return <td key={other} className="diag" />;
|
||||
const a = byPair.get(`${id}|${other}`);
|
||||
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 (
|
||||
<td key={other} title={text}>
|
||||
{a && (
|
||||
@@ -137,15 +134,14 @@ function AspectGrid({ chart }: { chart: Chart }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** Positions, angles, house cusps and aspects of a natal chart. */
|
||||
export function ChartTables({ chart }: { chart: Chart }) {
|
||||
/** Positions, angles and house cusps of a natal chart. */
|
||||
export function PositionTables({ chart }: { chart: Chart }) {
|
||||
const result = chart.chart;
|
||||
const timeKnown = chart.highlights.time_known;
|
||||
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,
|
||||
);
|
||||
const fortune = result.lots?.fortune;
|
||||
const aspects = [...(result.aspects ?? [])].sort((a, b) => a.orb - b.orb);
|
||||
|
||||
return (
|
||||
<div className="field" style={{ gap: 24 }}>
|
||||
@@ -230,57 +226,6 @@ export function ChartTables({ chart }: { chart: Chart }) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{aspects.length > 0 && (
|
||||
<div className="field" style={{ gap: 12 }}>
|
||||
<h3>Fényszögek</h3>
|
||||
<AspectGrid chart={chart} />
|
||||
<details className="details">
|
||||
<summary>Részletek: orbisz, közeledő vagy távolodó</summary>
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Fényszög</th>
|
||||
<th scope="col">Orbisz</th>
|
||||
<th scope="col">
|
||||
<span className="sr-only">Közeledő vagy távolodó</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{aspects.map((a) => {
|
||||
const info = ASPECTS[a.aspect];
|
||||
return (
|
||||
<tr key={`${a.point1}-${a.point2}-${a.aspect}`}>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[a.point1]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.point1)}{" "}
|
||||
<span className={`aspect-tag aspect-${info?.kind ?? "neutral"}`}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{info?.glyph}
|
||||
</span>{" "}
|
||||
{info?.hu ?? a.aspect}
|
||||
</span>{" "}
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[a.point2]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.point2)}
|
||||
</td>
|
||||
<td className="num">{orbText(a.orb)}</td>
|
||||
<td className="muted" style={{ fontSize: 13 }}>
|
||||
{a.applying === true ? "közeledő" : a.applying === false ? "távolodó" : ""}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</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
|
||||
@@ -290,3 +235,53 @@ export function ChartTables({ chart }: { chart: Chart }) {
|
||||
</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">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Fényszög</th>
|
||||
<th scope="col">Orbisz</th>
|
||||
<th scope="col">
|
||||
<span className="sr-only">Közeledő vagy távolodó</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{aspects.map((a) => {
|
||||
const info = ASPECTS[a.aspect];
|
||||
return (
|
||||
<tr key={`${a.point1}-${a.point2}-${a.aspect}`}>
|
||||
<td>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[a.point1]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.point1)}{" "}
|
||||
<span className={`aspect-tag aspect-${info?.kind ?? "neutral"}`}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{info?.glyph}
|
||||
</span>{" "}
|
||||
{info?.hu ?? a.aspect}
|
||||
</span>{" "}
|
||||
<span className="sym" aria-hidden="true">
|
||||
{POINTS[a.point2]?.glyph}
|
||||
</span>{" "}
|
||||
{pointName(a.point2)}
|
||||
</td>
|
||||
<td className="num">{orbText(a.orb)}</td>
|
||||
<td className="muted" style={{ fontSize: 13 }}>
|
||||
{a.applying === true ? "közeledő" : a.applying === false ? "távolodó" : ""}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function DetailedAnalysis({
|
||||
|
||||
if (analysis?.status === "done" && analysis.content) {
|
||||
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>
|
||||
<AnalysisView content={analysis.content} />
|
||||
</section>
|
||||
@@ -87,7 +87,7 @@ export function DetailedAnalysis({
|
||||
|
||||
if (waiting) {
|
||||
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>
|
||||
<AnalysisLoading
|
||||
title="Készül az elemzésed"
|
||||
@@ -98,7 +98,7 @@ export function DetailedAnalysis({
|
||||
}
|
||||
|
||||
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>
|
||||
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
|
||||
<p className="muted">
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user