Tree view: add "Back to default person" recenter link
Once you recenter the tree on someone, there was no quick way back to the tree's home/default person. Add a header link (shown only when a home person is set and you're not already on them) that recenters the chart on home_person_id via the existing goTo() — works in landscape, portrait, and fan modes. Labels with the home person's name for clarity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Justin Paul <justin@jpaul.me>
This commit is contained in:
@@ -42,6 +42,8 @@ export default function TreePage() {
|
|||||||
const [events, setEvents] = useState<Event[]>([]);
|
const [events, setEvents] = useState<Event[]>([]);
|
||||||
const [status, setStatus] = useState<"loading" | "empty" | "ready" | "error">("loading");
|
const [status, setStatus] = useState<"loading" | "empty" | "ready" | "error">("loading");
|
||||||
const [focusId, setFocusId] = useState<string | null>(null);
|
const [focusId, setFocusId] = useState<string | null>(null);
|
||||||
|
// The tree's default/home person — lets us offer a "recenter on default" jump.
|
||||||
|
const [homeId, setHomeId] = useState<string | null>(null);
|
||||||
const [mode, setMode] = useState<Mode>("landscape");
|
const [mode, setMode] = useState<Mode>("landscape");
|
||||||
const [renderNote, setRenderNote] = useState<string | null>(null);
|
const [renderNote, setRenderNote] = useState<string | null>(null);
|
||||||
|
|
||||||
@@ -67,6 +69,7 @@ export default function TreePage() {
|
|||||||
setPeople(ppl);
|
setPeople(ppl);
|
||||||
setRels(r.data ?? []);
|
setRels(r.data ?? []);
|
||||||
setEvents(e.data ?? []);
|
setEvents(e.data ?? []);
|
||||||
|
setHomeId(homeId);
|
||||||
// Honor an explicit ?focus first (came from a person page / a shared
|
// Honor an explicit ?focus first (came from a person page / a shared
|
||||||
// link), then the tree's default/home person, then the first person.
|
// link), then the tree's default/home person, then the first person.
|
||||||
const fromUrl = initialFocus.current && ppl.some((x) => x.id === initialFocus.current)
|
const fromUrl = initialFocus.current && ppl.some((x) => x.id === initialFocus.current)
|
||||||
@@ -288,6 +291,16 @@ export default function TreePage() {
|
|||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{homeId && focusId !== homeId && (
|
||||||
|
<button
|
||||||
|
onClick={() => goTo(homeId)}
|
||||||
|
className="text-sm text-bronze hover:underline"
|
||||||
|
title={`Recenter on the tree's default person (${nameOf(homeId)})`}
|
||||||
|
>
|
||||||
|
↩ Back to default person
|
||||||
|
<span className="text-[var(--muted)]"> · {nameOf(homeId)}</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="flex items-center rounded-lg border border-[var(--border)] p-0.5">
|
<div className="flex items-center rounded-lg border border-[var(--border)] p-0.5">
|
||||||
|
|||||||
Reference in New Issue
Block a user