From 0e01f88f315ebf464b155e68d41cf6b6ceae4df5 Mon Sep 17 00:00:00 2001 From: feco Date: Tue, 17 Nov 2026 10:43:03 +0000 Subject: [PATCH] Summary card links to the detailed analysis tab Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- services/frontend/src/app/globals.css | 6 +++++ .../frontend/src/app/kepletek/[id]/page.tsx | 2 +- .../frontend/src/components/ChartSummary.tsx | 23 ++++++++++++++++++- services/frontend/src/components/Tabs.tsx | 22 +++++++++++++++--- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/services/frontend/src/app/globals.css b/services/frontend/src/app/globals.css index 30a3467..56e5420 100644 --- a/services/frontend/src/app/globals.css +++ b/services/frontend/src/app/globals.css @@ -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; } } diff --git a/services/frontend/src/app/kepletek/[id]/page.tsx b/services/frontend/src/app/kepletek/[id]/page.tsx index da8a1cb..405d890 100644 --- a/services/frontend/src/app/kepletek/[id]/page.tsx +++ b/services/frontend/src/app/kepletek/[id]/page.tsx @@ -59,7 +59,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
- + {(elements || modalities || phase) && (
diff --git a/services/frontend/src/components/ChartSummary.tsx b/services/frontend/src/components/ChartSummary.tsx index b971365..5f82d79 100644 --- a/services/frontend/src/components/ChartSummary.tsx +++ b/services/frontend/src/components/ChartSummary.tsx @@ -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(initial); const [gaveUp, setGaveUp] = useState(false); const done = summary?.status === "done"; @@ -57,6 +67,17 @@ export function ChartSummary({ chartId, initial }: { chartId: string; initial: A

+ { + e.preventDefault(); + openTab("elemzes"); + }} + > + {detailedDone ? "Elolvasom a részletes elemzést" : "Kérj részletes elemzést: hat fejezet a képletedről"} + + ) : ( <> diff --git a/services/frontend/src/components/Tabs.tsx b/services/frontend/src/components/Tabs.tsx index f8976f5..97a324d 100644 --- a/services/frontend/src/components/Tabs.tsx +++ b/services/frontend/src/components/Tabs.tsx @@ -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(null); + + // A link to # (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 ( -
+
{tabs.map((t, i) => (