Summary card links to the detailed analysis tab
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -191,6 +191,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
|
||||
.summary-title { font-size: 26px; }
|
||||
.summary-text { font-size: 16px; line-height: 1.65; color: var(--ink-2); }
|
||||
.summary-more {
|
||||
margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); width: 100%;
|
||||
color: var(--gold); font-weight: 500; text-decoration: none;
|
||||
}
|
||||
.summary-more:hover { text-decoration: underline; text-underline-offset: 3px; }
|
||||
.summary-text strong { color: var(--ink); font-weight: 600; }
|
||||
.skeleton { display: flex; flex-direction: column; gap: 8px; }
|
||||
.skeleton span { height: 12px; border-radius: 6px; background: var(--line); animation: pulse 1.4s ease-in-out infinite; }
|
||||
@@ -322,5 +327,6 @@ td.num { font-variant-numeric: tabular-nums; 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; }
|
||||
.tabs { scroll-margin-top: 16px; }
|
||||
.tab-panel { padding-top: 20px; }
|
||||
@media (max-width: 640px) { .tab { padding: 12px 10px; font-size: 14px; } }
|
||||
|
||||
@@ -59,7 +59,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
<WheelLegend />
|
||||
</div>
|
||||
<div className="field chart-side">
|
||||
<ChartSummary chartId={chart.id} initial={summary} />
|
||||
<ChartSummary chartId={chart.id} initial={summary} detailedDone={detailed?.status === "done"} />
|
||||
<BigThree chart={chart} />
|
||||
{(elements || modalities || phase) && (
|
||||
<div className="card" style={{ gap: 12 }}>
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { Analysis } from "@/lib/types";
|
||||
|
||||
import { AnalysisLoading } from "./AnalysisLoading";
|
||||
import { Rich } from "./Rich";
|
||||
import { openTab } from "./Tabs";
|
||||
|
||||
const POLL_MS = 3000;
|
||||
const MAX_POLLS = 60;
|
||||
@@ -16,7 +17,16 @@ const MAX_POLLS = 60;
|
||||
* saved; this asks for it (queueing it again if it failed) and polls until the
|
||||
* worker has written it.
|
||||
*/
|
||||
export function ChartSummary({ chartId, initial }: { chartId: string; initial: Analysis | null }) {
|
||||
export function ChartSummary({
|
||||
chartId,
|
||||
initial,
|
||||
detailedDone = false,
|
||||
}: {
|
||||
chartId: string;
|
||||
initial: Analysis | null;
|
||||
/** The detailed analysis is ready: the link says so instead of offering it. */
|
||||
detailedDone?: boolean;
|
||||
}) {
|
||||
const [summary, setSummary] = useState<Analysis | null>(initial);
|
||||
const [gaveUp, setGaveUp] = useState(false);
|
||||
const done = summary?.status === "done";
|
||||
@@ -57,6 +67,17 @@ export function ChartSummary({ chartId, initial }: { chartId: string; initial: A
|
||||
<p className="summary-text">
|
||||
<Rich text={content.summary ?? ""} />
|
||||
</p>
|
||||
<a
|
||||
href="#elemzes"
|
||||
className="summary-more"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
openTab("elemzes");
|
||||
}}
|
||||
>
|
||||
{detailedDone ? "Elolvasom a részletes elemzést" : "Kérj részletes elemzést: hat fejezet a képletedről"}
|
||||
<span aria-hidden="true"> →</span>
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -9,13 +9,29 @@ export type Tab = { id: string; label: string; content: ReactNode };
|
||||
* shared link opens the same tab. Hidden panels stay mounted: a running
|
||||
* analysis keeps polling while another tab is open.
|
||||
*/
|
||||
/** Opens a tab from anywhere on the page (also when the hash is already that tab). */
|
||||
export function openTab(id: string) {
|
||||
history.replaceState(null, "", `#${id}`);
|
||||
window.dispatchEvent(new HashChangeEvent("hashchange"));
|
||||
}
|
||||
|
||||
export function Tabs({ tabs, label }: { tabs: Tab[]; label: string }) {
|
||||
const [active, setActive] = useState(tabs[0]?.id);
|
||||
const buttons = useRef<(HTMLButtonElement | null)[]>([]);
|
||||
|
||||
const root = useRef<HTMLDivElement>(null);
|
||||
|
||||
// A link to #<tab> (on load, or from elsewhere on the page) opens that tab and scrolls to it.
|
||||
useEffect(() => {
|
||||
const fromHash = window.location.hash.slice(1);
|
||||
if (tabs.some((t) => t.id === fromHash)) setActive(fromHash);
|
||||
const open = () => {
|
||||
const id = window.location.hash.slice(1);
|
||||
if (!tabs.some((t) => t.id === id)) return;
|
||||
setActive(id);
|
||||
root.current?.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
};
|
||||
open();
|
||||
window.addEventListener("hashchange", open);
|
||||
return () => window.removeEventListener("hashchange", open);
|
||||
}, [tabs]);
|
||||
|
||||
function choose(id: string) {
|
||||
@@ -33,7 +49,7 @@ export function Tabs({ tabs, label }: { tabs: Tab[]; label: string }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="tabs">
|
||||
<div className="tabs" ref={root}>
|
||||
<div className="tab-list" role="tablist" aria-label={label}>
|
||||
{tabs.map((t, i) => (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user