From ef46733329418501f04aee5e0f7185d135d827f8 Mon Sep 17 00:00:00 2001 From: IliesAllali Date: Mon, 19 Oct 2026 21:50:40 +0200 Subject: [PATCH] onglets de familles : une belle-famille trop large devient son propre arbre MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Une belle-famille plus large qu'un écran (FAMILY_TAB_PX) n'est plus dessinée dans l'arbre : elle devient un onglet, le même arbre recalculé avec le conjoint comme référence. Ses personnes sortent du placement, le fil de ses parents vers le conjoint n'est pas dessiné. - Le conjoint porte un badge « Famille X · n › » sous ses dates, un clic ouvre l'onglet. - Barre d'onglets en haut à gauche : la famille de départ d'abord, puis chaque famille rencontrée, sans doublon (une famille déjà en onglet se reconnaît à sa personne de référence parmi les membres). - Retrait des clusters, cartes de famille, échos, bandeau et carte des familles. Co-Authored-By: Claude Fable 5.1 --- frontend/src/components/Galaxy.css | 49 +++++ frontend/src/components/Galaxy.jsx | 71 ++++-- frontend/src/components/galaxy/blockLayout.js | 159 +++++--------- frontend/src/components/galaxy/constants.js | 3 - frontend/src/components/galaxy/renderers.js | 204 ++---------------- .../galaxy/useGalaxyInteractions.js | 13 +- frontend/src/i18n/en/arbre.js | 1 + 7 files changed, 183 insertions(+), 317 deletions(-) diff --git a/frontend/src/components/Galaxy.css b/frontend/src/components/Galaxy.css index dd9c103..b730d50 100644 --- a/frontend/src/components/Galaxy.css +++ b/frontend/src/components/Galaxy.css @@ -43,3 +43,52 @@ font-size: 13px; } } + +/* ============================================================ + Onglets de familles : un onglet par famille, en haut à gauche + ============================================================ */ + +.family-tabs { + position: fixed; + top: 16px; + left: 16px; + z-index: 500; + display: flex; + gap: 6px; + max-width: calc(100vw - 120px); + overflow-x: auto; + scrollbar-width: none; + padding: 4px; +} +.family-tabs::-webkit-scrollbar { display: none; } + +.family-tab { + flex: 0 0 auto; + display: inline-flex; + align-items: baseline; + gap: 7px; + padding: 7px 14px 8px; + border-radius: 999px; + border: 1px solid #EBE6DF; + background: #FFFFFF; + color: #2A2622; + font-family: "Newsreader", Georgia, serif; + font-size: 15px; + line-height: 1; + cursor: pointer; + white-space: nowrap; +} +.family-tab:hover { border-color: #D9CFC6; } +.family-tab:focus-visible { outline: 2px solid #C9553D; outline-offset: 2px; } +.family-tab.is-active { background: #2A2622; border-color: #2A2622; color: #FFFFFF; } +.family-tab-count { + font-family: "DM Sans", system-ui, sans-serif; + font-size: 11px; + color: #93402A; +} +.family-tab.is-active .family-tab-count { color: #EDB6A4; } + +@media (max-width: 768px) { + .family-tabs { top: 10px; left: 10px; max-width: calc(100vw - 84px); } + .family-tab { font-size: 14px; padding: 6px 12px 7px; } +} diff --git a/frontend/src/components/Galaxy.jsx b/frontend/src/components/Galaxy.jsx index 60c722d..d35c2ff 100644 --- a/frontend/src/components/Galaxy.jsx +++ b/frontend/src/components/Galaxy.jsx @@ -8,11 +8,12 @@ import { computeBlockLayout } from './galaxy/blockLayout' // Placement par blocs familiaux par défaut (mesures : tools/layout-bench). ?layout=sugiyama = placement Sugiyama. const USE_BLOCK_LAYOUT = typeof window === 'undefined' || new URLSearchParams(window.location.search).get('layout') !== 'sugiyama' import { findPathBFS } from './galaxy/pathfinding' -import { drawBackground, drawCoupleLinks, drawFiliations, drawAnnotations, drawPathHighlight, drawNodes, drawRenvoiPills, nodeRadius, drawFamilyMap, familyAt, drawFamilyBanner } from './galaxy/renderers' +import { drawBackground, drawCoupleLinks, drawFiliations, drawAnnotations, drawPathHighlight, drawNodes, drawRenvoiPills, nodeRadius } from './galaxy/renderers' import { buildSiblingGroups, moveInOrder, pickSlot, rubberBand, springStep, isSettled, buildOrderPayload, filiationsWithOrder } from './galaxy/siblingReorder' import { annotations as annotationData } from '../data/mockData' import { useImageCache } from './galaxy/useImageCache' import { useGalaxyInteractions } from './galaxy/useGalaxyInteractions' +import { t as tr } from '../i18n/index.js' import './Galaxy.css' // Assez bas pour cadrer un grand arbre entier à l'ouverture @@ -27,7 +28,6 @@ function approach(prev, target, k, eps = 1e-3) { } const MAX_SCALE = 3.2 // Carte des familles : l'arbre s'efface entre ces deux échelles, les tuiles de familles apparaissent -const MAP_SCALE = 0.25 // Ouverture sur la personne de départ quand l'arbre entier serait illisible const FOCUS_MIN_READABLE_SCALE = 0.5 const FOCUS_SCALE = 0.95 @@ -44,14 +44,27 @@ const prefersReducedMotion = () => typeof window !== 'undefined' && window.match const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlightIds = [], graphRevision = 0, annotationHandlers = null, transformReadRef = null, zoomApiRef = null, focusPersonId = null, assetRevision = 0, photoHint = false, onPhotoPlaceholderClick = null, reorderEnabled = false, onReorderSiblings = null }) => { const canvasRef = useRef(null) + // Onglets de familles : la personne de référence de l'arbre affiché (celle de départ, puis le conjoint + // dont on ouvre la famille), et la liste des familles rencontrées, dans l'ordre des mariages + const layoutDataRef = useRef(null) + const [activeRef, setActiveRef] = useState(focusPersonId) + const [tabs, setTabs] = useState([]) + const startRefRef = useRef(focusPersonId) + useEffect(() => { startRefRef.current = focusPersonId; setActiveRef(focusPersonId); setTabs([]) }, [focusPersonId]) // Lu au calcul du cadrage seulement : changer de personne de départ ne recadre pas une vue en cours const focusPersonIdRef = useRef(focusPersonId) // Mis à jour hors du rendu, avant l'effet de cadrage déclaré plus bas (même phase, ordre de déclaration) - useEffect(() => { focusPersonIdRef.current = focusPersonId }, [focusPersonId]) + useEffect(() => { focusPersonIdRef.current = activeRef }, [activeRef]) + // Clic sur un badge : l'onglet de cette famille s'il existe déjà (la même famille vue depuis un autre + // conjoint), sinon un nouvel onglet avec ce conjoint comme référence + const openFamily = useCallback((anchorId) => { + const fam = layoutDataRef.current?.families?.find((f) => f.anchorId === anchorId) + const known = fam && tabs.find((tb) => `p-${tb.referenceId}` === String(anchorId) || fam.members.includes(String(tb.referenceId))) + setActiveRef(known ? known.referenceId : String(anchorId).replace(/^p-/, '')) + }, [tabs]) // Propriétaire : un portrait vide survolé montre « + photo » const photoHintRef = useRef(photoHint) useEffect(() => { photoHintRef.current = photoHint }, [photoHint]) - const layoutDataRef = useRef(null) const [layoutReady, setLayoutReady] = useState(false) const transformRef = useRef({ x: 0, y: 0, scale: 1 }) @@ -141,7 +154,7 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig canvasRef, transformRef, targetTransformRef, layoutDataRef, nodeRandomDataRef, entranceRef, hoveredNodeIdRef: hoveredNodeId, hoveredMediaKeyRef: hoveredMediaKey, mouseWorldPosRef: mouseWorldPos, - getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick, + getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick, onOpenFamily: openFamily, annotationHandlers, minScale: MIN_SCALE, maxScale: MAX_SCALE, @@ -561,7 +574,24 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig layoutDataRef.current = result needsRedrawRef.current = true setLayoutReady(true) - }, [graphRevision]) + // Onglets : la famille affichée d'abord, puis chaque belle-famille rencontrée, sans doublon (une famille déjà + // en onglet se reconnaît à sa personne de référence parmi les membres) + const fams = result.families || [] + if (fams.length) setTabs((prev) => { + // La liste commence toujours par la famille de départ ; un placement calculé pour une autre référence + // avant qu'elle soit connue (arbre chargé avant sa personne de départ) ne compte pas + const start = String(startRefRef.current) + const next = prev[0] && String(prev[0].referenceId) === start ? [...prev] : [] + const main = fams[0] + if (!next.length && String(main.referenceId) !== start) return prev + if (!next.some((tb) => String(tb.referenceId) === String(main.referenceId))) next.push({ referenceId: main.referenceId, label: main.label, count: main.count }) + for (const f of fams.slice(1)) { + if (next.some((tb) => `p-${tb.referenceId}` === String(f.anchorId) || f.members.includes(String(tb.referenceId)))) continue + next.push({ referenceId: String(f.anchorId).replace(/^p-/, ''), label: f.label, count: f.count }) + } + return next + }) + }, [graphRevision, activeRef]) // Sync selectedPersonId useEffect(() => { @@ -792,10 +822,6 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig // Rien n'a changé : on ne redessine pas if (!dirty) { rafId = requestAnimationFrame(animate); return } - // Carte des familles : passé MAP_SCALE, l'arbre laisse la place à la carte, bascule nette - const families = layoutData.families || [] - const mapOn = families.length > 1 && scale < MAP_SCALE - // Positions animées, calculées seulement quand on redessine const posMap = new Map() layoutData.children.forEach(node => { @@ -817,7 +843,6 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig const cssW = canvas.width / dprRef.current const cssH = canvas.height / dprRef.current const view = { x0: -x / scale, y0: -y / scale, x1: (cssW - x) / scale, y1: (cssH - y) / scale, scale } - if (!mapOn) { drawCoupleLinks(ctx, coupleBarMeta, posMap, nodeMap, nodeRandomDataRef.current, entrance, entranceActive, elapsed, view) drawFiliations(ctx, layoutData.edges, posMap, nodeMap, nodeRandomDataRef.current, entrance, entranceActive, elapsed, view) drawPathHighlight(ctx, { @@ -845,14 +870,6 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig liftScales: liftScalesRef.current, }) drawRenvoiPills(ctx) - } - if (mapOn || families.length > 1) { - ctx.save() - ctx.setTransform(dprRef.current, 0, 0, dprRef.current, 0, 0) - if (mapOn) drawFamilyMap(ctx, families, cssW, cssH) - else drawFamilyBanner(ctx, familyAt(families, view)) - ctx.restore() - } // Annotations dessinées APRES les noeuds pour que stickers/texte soient au-dessus // Annotations : ancrer aux personnes proches pour qu'elles suivent le layout const personPosMap = new Map() @@ -1050,6 +1067,22 @@ const Galaxy = ({ onPersonSelect, onMediaSelect, selectedPersonId, searchHighlig {displayLabel && (
{displayLabel}
)} + {tabs.length > 1 && ( + + )} ) } diff --git a/frontend/src/components/galaxy/blockLayout.js b/frontend/src/components/galaxy/blockLayout.js index 6656f72..a8daead 100644 --- a/frontend/src/components/galaxy/blockLayout.js +++ b/frontend/src/components/galaxy/blockLayout.js @@ -1,5 +1,4 @@ import { computeLayout, componentOrderPerGen, chainGap } from './elkLayout' -import { PERSON_W, PERSON_H, FAMILY_CARD_W, FAMILY_CARD_H } from './constants' // ============================================================ // Layout par blocs familiaux (Reingold-Tilford adapté aux couples) @@ -44,7 +43,9 @@ const PARENT_SHIFT_PX = 400 const SIDE_SWITCH_PX = 1440 // Carte de famille et pont (maquette A, retenue le 19/10). Une belle-famille plus large que ça ne se colle pas à // son enfant : elle devient un cluster dessiné à part, et une carte prend sa place au-dessus du conjoint -const CLUSTER_PX = 2880 +// Une belle-famille plus large que ça n'est pas dessinée dans cet arbre : elle devient un onglet (son propre +// arbre, calculé avec le conjoint comme référence) et le conjoint porte un badge vers elle. +const FAMILY_TAB_PX = 2880 // Le fil d'une filiation union → enfant : une personne d'une autre famille, sur la ligne de l'enfant, // entre l'aplomb de l'union et l'enfant, est croisée. Frères et sœurs et leurs conjoint(e)s ne comptent pas @@ -86,10 +87,6 @@ const extentOf = (rows) => { } const overlaps = (l, r, list, gap) => list.some(([a, b]) => l < b + gap && r > a - gap) -// Les grosses belles-familles (clusters) se rangent du côté où leur conjoint se trouve dans la lignée -// principale : gauche s'il est dans la moitié gauche, droite sinon. Ce côté ne se connaît qu'une fois la -// lignée posée, d'où une seconde passe quand un cluster s'est construit du mauvais côté. Le couple se tourne -// alors vers la famille, et la carte au-dessus du conjoint se pose de ce côté-là. // Règle globale (Patch, 19/10) : l'arbre s'ouvre à partir de la personne de référence. Toute belle-famille, // grosse ou petite, part du côté opposé à la référence (à droite pour un conjoint à sa droite), le couple se // tourne vers elle. Ce côté ne se connaît qu'une fois la lignée posée, d'où une seconde passe. @@ -101,11 +98,12 @@ export function computeBlockLayout(graphData = null, referenceId = null) { for (let pass = 0; pass < 4 && result._inlaws?.length; pass++) { const byId = new Map(result.children.map(n => [n.id, n])) const ref = referenceId != null ? byId.get(`p-${referenceId}`) : null - const main = result.families?.find(f => f.id === 'main') - const pivot = ref ? ref.x + ref.width / 2 : main ? (main.bbox.x0 + main.bbox.x1) / 2 : 0 + const persons = result.children.filter(n => n._type === 'person') + const pivot = ref ? ref.x + ref.width / 2 : persons.length ? (Math.min(...persons.map(n => n.x)) + Math.max(...persons.map(n => n.x + n.width))) / 2 : 0 let changed = false for (const { anchorId, side } of result._inlaws) { const a = byId.get(anchorId) + if (!a) continue // conjoint d'une famille devenue onglet : pas dans cet arbre const want = a.x + a.width / 2 < pivot ? -1 : 1 if (want !== side && forced.get(anchorId) !== want) { forced.set(anchorId, want); changed = true } } @@ -224,8 +222,8 @@ function layoutOnce(graphData, referenceId, forcedSide) { const placed = new Set() const externalEdges = new Set() // `${union}>${enfant}` : enfant dessiné sous une autre lignée const detached = [] // familles qu'on n'a pas pu coller à leur enfant (trop loin) : posées à part, renvoi - const clusters = [] // grosses belles-familles dessinées à part : { block, anchorId, cardId, echoId, mainCardId } - const rowStep = (() => { const ys = [...new Set(nodes.map(n => n.y))].sort((a, b) => a - b); return ys.length > 1 ? ys[1] - ys[0] : PERSON_H + 60 })() + const tabs = [] // belles-familles trop larges pour cet arbre, devenues onglets : { anchorId, pu, label, count, members } + const hiddenChains = new Set() // chaînes des familles devenues onglets : pas dessinées dans cet arbre const attachedEdges = new Set() // `${union}>${enfant}` : fil d'une famille collée à son enfant, toujours dessiné // Imbrique des blocs de gauche à droite, rangée par rangée @@ -274,22 +272,9 @@ function layoutOnce(graphData, referenceId, forcedSide) { // Place fantôme d'un enfant déjà dessiné ailleurs : il garde sa place dans l'ordre de la fratrie et // dans le centrage des parents, sans occuper de contour (c'est l'enfant réel qui l'occupe) - // Pendant la reconstruction d'un cluster, la place de la carte inverse est réservée sous le fantôme du conjoint - let cardUnder = null const ghostBlock = (kid) => { const n = byId.get(kid) - const rows = new Map([[n._generation, [[0, n.width]]]]) - if (kid === cardUnder) rows.set(n._generation + 1, [[(n.width - FAMILY_CARD_W) / 2, (n.width + FAMILY_CARD_W) / 2]]) - return { ghost: true, withCard: kid === cardUnder, kid, rows, members: new Set(), external: [], gen: n._generation, chain: [0, n.width], rel: () => null, width: n.width, place() {} } - } - const CARD_SIDE_PX = 400 - const freeSpotNear = (desired, w, list, prefer = 0) => { - if (!overlaps(desired, desired + w, list, FAMILY_GAP)) return desired - const candidates = list.flatMap(([l, r]) => [r + FAMILY_GAP, l - FAMILY_GAP - w]).filter(c => !overlaps(c, c + w, list, FAMILY_GAP)) - if (!candidates.length) return null - // Le côté de la famille est préféré tant qu'il ne coûte pas plus de CARD_SIDE_PX - const cost = (c) => Math.abs(c - desired) + (prefer && Math.sign(c - desired) === -prefer ? CARD_SIDE_PX : 0) - return candidates.reduce((best, c) => (cost(c) < cost(best) ? c : best)) + return { ghost: true, kid, rows: new Map([[n._generation, [[0, n.width]]]]), members: new Set(), external: [], gen: n._generation, chain: [0, n.width], rel: () => null, width: n.width, place() {} } } // Famille attachée à un conjoint : l'enfant à coller (ancre) doit finir au bout de sa fratrie, du côté du @@ -354,8 +339,7 @@ function layoutOnce(graphData, referenceId, forcedSide) { childBlocks.push(...kids) const packed = packBlocks(childBlocks, FAMILY_GAP) const rows = new Map() - // Un fantôme ne compte pas dans le contour, sauf s'il porte la carte inverse d'un cluster (l'écho y est dessiné) - childBlocks.forEach((b, i) => { if (!b.ghost || b.withCard) mergeRows(rows, b.rows, packed.xs[i]) }) + childBlocks.forEach((b, i) => { if (!b.ghost) mergeRows(rows, b.rows, packed.xs[i]) }) // Familles des conjoints de la chaîne pas encore dessinées : construites entières depuis leur ancêtre // le plus haut. Le couple se tourne vers cette famille (conjoint du côté où elle se pose). Une famille @@ -375,38 +359,27 @@ function layoutOnce(graphData, referenceId, forcedSide) { if (placed.has(top)) continue const side = forcedSide.get(id) ?? (chain.length > 3 ? (chain.indexOf(id) < chain.length / 2 ? -1 : 1) : (outer || (chain.indexOf(id) < chain.length / 2 ? -1 : 1))) const saved = anchor - const clustersBefore = clusters.length + const tabsBefore = tabs.length const externalBefore = new Set(externalEdges) anchor = { kid: id, end: side < 0 ? 'right' : 'left', path: pathOf(id) } - let block = buildBlock(top, null, side) + const block = buildBlock(top, null, side) anchor = saved - if (block.width > CLUSTER_PX) { - // La famille devient un cluster. On la reconstruit avec, sous le fantôme du conjoint, la place réservée - // de la carte inverse. La première construction ne laisse aucune trace : ses clusters imbriqués (et leurs - // chaînes), les chaînes qu'elle a posées et les arêtes externes qu'elle a notées sont oubliés avec elle. - const unplace = (members) => { for (const ch of new Set([...members].map(m => chainOf.get(m)).filter(Boolean))) placed.delete(ch) } - for (const c of clusters.splice(clustersBefore)) { const i = nodes.findIndex(n => n.id === c.cardId); if (i >= 0) nodes.splice(i, 1); byId.delete(c.cardId); unplace(c.block.members) } + if (block.width > FAMILY_TAB_PX) { + // Trop large pour cet arbre : la famille devient un onglet et n'est pas dessinée ici. Sa construction ne + // laisse aucune trace (onglets imbriqués, chaînes posées, arêtes externes), et le fil de ses parents + // vers le conjoint est caché : c'est le badge du conjoint qui dit où est sa famille. + const chainsOf = (members) => new Set([...members].map(m => chainOf.get(m)).filter(Boolean)) + const unplace = (members) => { for (const ch of chainsOf(members)) { placed.delete(ch); hiddenChains.delete(ch) } } + for (const tb of tabs.splice(tabsBefore)) { unplace(tb.members); byId.get(tb.anchorId)._familyTab = null } unplace(block.members) for (const e of [...externalEdges]) if (!externalBefore.has(e)) externalEdges.delete(e) - const savedCard = cardUnder - cardUnder = id - anchor = { kid: id, end: side < 0 ? 'right' : 'left', path: pathOf(id) } - block = buildBlock(top, null, side) - anchor = saved - cardUnder = savedCard - // Ici, une carte de famille tient la place de ses parents, juste au-dessus de lui + for (const ch of chainsOf(block.members)) hiddenChains.add(ch) const A = byId.get(id) - const cardId = `fam-${id}`, echoId = `echo-${id}`, mainCardId = `fam-main-${id}` const partners = [byId.get(pu)?._data?.p1Key, byId.get(pu)?._data?.p2Key].map(k => byId.get(k)?._data).filter(Boolean) - const label = partners.find(d => d.lastName)?.lastName || A._data?.birthName || A._data?.lastName || '' - const people = [...block.members].map(m => byId.get(m)).filter(n => n?._type === 'person') - const portraits = [...people.filter(n => n._data?.photo), ...people.filter(n => !n._data?.photo)].slice(0, 4).map(n => n._data) - nodes.push({ id: cardId, _type: 'family', width: FAMILY_CARD_W, height: FAMILY_CARD_H, _generation: gen - 1, y: A.y - rowStep + (PERSON_H - FAMILY_CARD_H) / 2, _data: { label, count: people.length, portraits, targetId: echoId, stem: 'down', stemTo: id } }) - byId.set(cardId, nodes[nodes.length - 1]) - const card = { isCard: true, rows: new Map([[gen - 1, [[0, FAMILY_CARD_W]]]]), members: new Set([cardId]), external: [], gen: gen - 1, rel: (x) => (x === cardId ? 0 : null), chain: [0, FAMILY_CARD_W], width: FAMILY_CARD_W, place(x0) { pos.set(cardId, x0) } } - clusters.push({ block, anchorId: id, pu, cardId, echoId, mainCardId, label, people, side }) - built.push({ block: card, anchorId: id, side }) - orient(chain, kidOfChain ?? (chain.length === 3 ? (chain[0] === id ? chain[2] : chain[0]) : null), side) + const label = A._data?.birthName || partners.find(d => d.lastName)?.lastName || A._data?.lastName || '' + const members = new Set([...block.members].filter(m => byId.get(m)?._type === 'person')) + tabs.push({ anchorId: id, pu, label, count: members.size, members }) + A._familyTab = { anchorId: id, label, count: members.size } continue } built.push({ block, anchorId: id, side }) @@ -486,7 +459,6 @@ function layoutOnce(graphData, referenceId, forcedSide) { reserveParents(trial, rowX) for (const p of built) { if (chain.length !== 3) break - if (p.block.isCard) continue const ideal = idealOf(p, rowX) const x = pushHybrid(p.block.rows, ideal, trial, p.side, gen, FAMILY_GAP) const other = -p.side @@ -513,8 +485,8 @@ function layoutOnce(graphData, referenceId, forcedSide) { let maxPush = 0, sideOfMax = 0 for (const p of built) { const ideal = idealOf(p, rx) - const x = p.block.isCard ? (freeSpotNear(ideal, p.block.width, r.get(gen - 1) || [], p.side) ?? pushHybrid(p.block.rows, ideal, r, p.side, gen, FAMILY_GAP)) : pushHybrid(p.block.rows, ideal, r, p.side, gen, FAMILY_GAP) - if (!p.block.isCard && Math.abs(x - ideal) > maxPush) { maxPush = Math.abs(x - ideal); sideOfMax = p.side } + const x = pushHybrid(p.block.rows, ideal, r, p.side, gen, FAMILY_GAP) + if (Math.abs(x - ideal) > maxPush) { maxPush = Math.abs(x - ideal); sideOfMax = p.side } list.push({ block: p.block, x, ideal, anchorId: p.anchorId, side: p.side }) mergeRows(r, p.block.rows, x) } @@ -608,42 +580,26 @@ function layoutOnce(graphData, referenceId, forcedSide) { (isBloodChain(b) - isBloodChain(a)) || countDesc(b) - countDesc(a) || genOf(a) - genOf(b) || birthYearOf(a) - birthYearOf(b) || String(a[0]).localeCompare(String(b[0])) )) const free = [] - for (const r of roots) if (!placed.has(r)) free.push(buildBlock(r)) - for (const c of chains) if (!placed.has(c)) free.push(buildBlock(c)) + for (const r of roots) if (!placed.has(r) && !hiddenChains.has(r)) free.push(buildBlock(r)) + for (const c of chains) if (!placed.has(c) && !hiddenChains.has(c)) free.push(buildBlock(c)) free.push(...detached) - // Clusters : chaque grosse belle-famille à part, sur les mêmes rangées. Le conjoint y apparaît dans sa fratrie - // (écho de la même personne) avec, sous lui, la carte de la lignée qu'il a rejointe. Les deux cartes se répondent. - // Les clusters se rangent du côté de leur conjoint : à gauche de la lignée si le conjoint est dans la - // moitié gauche de sa fratrie, à droite sinon. L'orientation des gens et la place des familles se répondent. - const ordered = [...clusters.filter(c => c.side < 0).reverse().map(c => c.block), ...free, ...clusters.filter(c => c.side >= 0).map(c => c.block)] - const forest = packBlocks(ordered, FAMILY_GAP * 2) - ordered.forEach((b, i) => b.place(forest.xs[i])) - const xOfBlock = new Map(ordered.map((b, i) => [b, forest.xs[i]])) + const forest = packBlocks(free, FAMILY_GAP * 2) + free.forEach((b, i) => b.place(forest.xs[i])) const referenceNode = result.referenceId != null ? byId.get(`p-${result.referenceId}`) : null - const inCluster = new Set(clusters.flatMap(c => [...c.block.members])) - const mainPeople = nodes.filter(n => n._type === 'person' && !inCluster.has(n.id) && !n._echo) - clusters.forEach((c) => { - const A = byId.get(c.anchorId) - const ghostX = c.block.rel(c.anchorId) - const x0 = xOfBlock.get(c.block) - if (ghostX == null) return - pos.set(c.echoId, x0 + ghostX) - nodes.push({ id: c.echoId, _type: 'person', _data: A._data, width: PERSON_W, height: PERSON_H, _generation: A._generation, y: A.y, _echo: true, _echoOf: c.anchorId }) - byId.set(c.echoId, nodes[nodes.length - 1]) - const mainChain = chainOf.get(c.anchorId) || [] - const around = [...mainChain.filter(id => byId.get(id)._type === 'person' && id !== c.anchorId), ...mainChain.flatMap(id => childrenOfUnion.get(id) || [])].map(id => byId.get(id)?._data).filter(Boolean) - const mainLabel = referenceNode?._data?.lastName || around[0]?.lastName || '' - nodes.push({ id: c.mainCardId, _type: 'family', width: FAMILY_CARD_W, height: FAMILY_CARD_H, _generation: A._generation + 1, y: A.y + rowStep + (PERSON_H - FAMILY_CARD_H) / 2, _data: { label: mainLabel, count: mainPeople.length, portraits: around.slice(0, 4), targetId: c.anchorId, stem: 'up', stemTo: c.echoId } }) - byId.set(c.mainCardId, nodes[nodes.length - 1]) - pos.set(c.mainCardId, pos.get(c.echoId) + (PERSON_W - FAMILY_CARD_W) / 2) - // Le fil des parents va à l'écho dans le cluster ; vers le conjoint du plan principal, c'est la carte qui parle - for (const e of [...result.edges]) { - if (e.targets[0] !== c.anchorId || !c.block.members.has(e.sources[0])) continue - e._hidden = true - result.edges.push({ ...e, id: `${e.id}#echo`, targets: [c.echoId], _hidden: false }) - } - }) + // Le fil des parents d'un conjoint dont la famille est un onglet n'est pas dessiné : son badge dit où elle est + for (const tb of tabs) for (const e of result.edges) if (e.sources[0] === tb.pu && e.targets[0] === tb.anchorId) e._hidden = true + // Les familles devenues onglets sortent de cet arbre : leurs nœuds et leurs arêtes ne sont pas dessinés + if (hiddenChains.size) { + const hidden = new Set([...hiddenChains].flatMap(ch => ch)) + for (const n of nodes) if (n._type === 'unknown' && hidden.has(n.id.replace(/^unknown-/, 'p-'))) hidden.add(n.id) + result.children = nodes.filter(n => !hidden.has(n.id)) + // Un onglet se propose depuis le badge d'un conjoint dessiné : ceux dont le conjoint est caché avec sa famille tombent + for (let i = tabs.length - 1; i >= 0; i--) if (hidden.has(tabs[i].anchorId)) tabs.splice(i, 1) + result.edges = result.edges.filter(e => !hidden.has(e.sources[0]) && !hidden.has(e.targets[0])) + nodes.length = 0 + nodes.push(...result.children) + } // Réinjecter le X, normalisé à 0 ; Y inchangé (rangées) let minX = Infinity for (const n of nodes) if (pos.has(n.id)) minX = Math.min(minX, pos.get(n.id)) @@ -724,28 +680,13 @@ function layoutOnce(graphData, referenceId, forcedSide) { for (const r of list) byId.get(r.id)._railLift = Math.min(4, liftOf(r.id)) } - // Carte des familles (maquette J, 19/10) : au dézoom, chaque famille (la lignée principale, chaque cluster) - // devient une tuile, et chaque mariage entre familles un trait. Le dessin se fait dans Galaxy / renderers. - const familyOf = new Map() - clusters.forEach(c => { for (const m of c.block.members) familyOf.set(m, c.cardId); familyOf.set(c.echoId, c.cardId); familyOf.set(c.mainCardId, c.cardId) }) - const bboxOf = (ids) => { - const ps = ids.map(id => byId.get(id)).filter(n => n && n._type === 'person' && n.x != null) - if (!ps.length) return null - return { x0: Math.min(...ps.map(n => n.x)), y0: Math.min(...ps.map(n => n.y)), x1: Math.max(...ps.map(n => n.x + n.width)), y1: Math.max(...ps.map(n => n.y + n.height)) } - } - const portraitsOf = (ids) => { - const ps = ids.map(id => byId.get(id)).filter(n => n?._type === 'person' && !n._echo) - return [...ps.filter(n => n._data?.photo), ...ps.filter(n => !n._data?.photo)].slice(0, 6).map(n => n._data) - } - const mainIds = nodes.filter(n => !familyOf.has(n.id)).map(n => n.id) - nodes.forEach(n => { n._family = familyOf.get(n.id) || 'main' }) - const partnerOf = (id) => { const ch = chainOf.get(id) || []; return ch.find(x => x !== id && byId.get(x)?._type === 'person') } - const families = [ - { id: 'main', label: referenceNode?._data?.lastName || '', count: mainPeople.length, portraits: portraitsOf(mainIds), bbox: bboxOf(mainIds), links: [] }, - ...clusters.map(c => ({ id: c.cardId, side: c.side, anchorId: c.anchorId, label: c.label, count: c.people.length, portraits: portraitsOf([...c.block.members]), bbox: bboxOf([...c.block.members]), links: [{ to: 'main', label: [byId.get(c.anchorId)?._data?.firstName, byId.get(partnerOf(c.anchorId))?._data?.firstName].filter(Boolean).join(' et ') }] })), - ].filter(f => f.bbox) - families.forEach(f => { f.spread = { x: (f.bbox.x0 + f.bbox.x1) / 2, y: (f.bbox.y0 + f.bbox.y1) / 2 } }) - result.families = families + // Les familles de cet arbre : la lignée dessinée, puis chaque belle-famille devenue onglet. Galaxy en fait + // la barre d'onglets ; un onglet est le même arbre recalculé avec le conjoint comme référence. + const drawn = nodes.filter(n => n._type === 'person') + result.families = [ + { id: 'main', label: referenceNode?._data?.lastName || drawn[0]?._data?.lastName || '', count: drawn.length, referenceId: result.referenceId ?? null }, + ...tabs.map(tb => ({ id: tb.anchorId, anchorId: tb.anchorId, label: tb.label, count: tb.count, members: [...tb.members].map(m => m.replace(/^p-/, '')) })), + ] result._inlaws = inlaws return result diff --git a/frontend/src/components/galaxy/constants.js b/frontend/src/components/galaxy/constants.js index 13e9773..5a90fdc 100644 --- a/frontend/src/components/galaxy/constants.js +++ b/frontend/src/components/galaxy/constants.js @@ -16,9 +16,6 @@ export const COMPACT_SCALE = 0.6 export const COMPACT_R = PERSON_R * COMPACT_SCALE export const COMPACT_W = 40 export const COMPACT_JOIN_GAP = -18 -// Carte de famille : tient la place d'un couple au-dessus d'un conjoint dont la famille est dessinée à part -export const FAMILY_CARD_W = 200 -export const FAMILY_CARD_H = 76 export const MAX_ORBIT_MEDIAS = 3 export const ORBIT_RADIUS = 55 export const ORBIT_MEDIA_SIZE = 22 diff --git a/frontend/src/components/galaxy/renderers.js b/frontend/src/components/galaxy/renderers.js index 28ad404..3d63e21 100644 --- a/frontend/src/components/galaxy/renderers.js +++ b/frontend/src/components/galaxy/renderers.js @@ -201,6 +201,8 @@ export function drawCoupleLinks(ctx, coupleBarMeta, posMap, nodeMap, nodeRandomD // useGalaxyInteractions. // ============================================================ export const renvoiHitAreas = [] +// Badges « Famille X » sous les conjoints dont la famille est un onglet : { x0, y0, x1, y1, anchorId } +export const familyHitAreas = [] // Zones « + photo » : portraits vides, chez le propriétaire (cercle du nœud, rempli au dessin) export const photoPlaceholderHitAreas = [] const renvoiPills = [] @@ -250,186 +252,6 @@ function drawRenvoi(ctx, edge, sourcePos, targetPos, targetNode, childR, view) { ) } -// ============================================================ -// Carte de famille (maquette A, 19/10) : une belle-famille dessinée à part est représentée, à la place de -// ses parents au-dessus du conjoint, par une carte (nom, portraits, nombre) reliée au conjoint par un -// pont. Dans le cluster, la carte inverse se trouve sous l'écho du conjoint. Un clic mène de l'autre côté. -// ============================================================ -const CARD_FONT = '500 13px "Newsreader", Georgia, serif' -const CARD_SMALL = '400 10px "DM Sans", system-ui, sans-serif' -function drawFamilyCard(ctx, node, pos, posMap, progress, view) { - const { cx, cy } = pos - const w = node.width, h = node.height - const scale = view?.scale ?? 1 - const alpha = Math.min(1, progress * 1.5) - // Pont vers la personne qu'elle remplace ou qu'elle prolonge - const to = posMap.get(node._data.stemTo) - if (to) { - ctx.save() - ctx.globalAlpha = alpha - ctx.strokeStyle = FIL.color - ctx.lineWidth = FIL.width - ctx.setLineDash([]) - ctx.lineCap = 'round' - ctx.beginPath() - if (node._data.stem === 'down') { ctx.moveTo(cx, cy + h / 2); ctx.lineTo(to.cx, to.cy - PERSON_R - 2) } - else { ctx.moveTo(cx, cy - h / 2); ctx.lineTo(to.cx, to.cy + PERSON_R + 2) } - ctx.stroke() - ctx.restore() - } - ctx.save() - ctx.globalAlpha = alpha - ctx.fillStyle = '#FCF3EF' - ctx.strokeStyle = '#EDB6A4' - ctx.lineWidth = 0.9 - ctx.beginPath() - ctx.roundRect(cx - w / 2, cy - h / 2, w, h, 14) - ctx.fill() - ctx.stroke() - // Quatre petits portraits, en mosaïque - const ps = node._data.portraits || [] - ps.forEach((p, i) => { - const px = cx - w / 2 + 16 + (i % 2) * 24, py = cy - 22 + Math.floor(i / 2) * 24 - ctx.fillStyle = '#F2EFEA' - ctx.strokeStyle = '#E3DED6' - ctx.lineWidth = 0.7 - ctx.beginPath() - ctx.roundRect(px, py, 20, 20, 3) - ctx.fill() - ctx.stroke() - ctx.fillStyle = COLORS.textLight - ctx.font = '400 8px "Newsreader", Georgia, serif' - ctx.textAlign = 'center' - ctx.textBaseline = 'middle' - ctx.fillText(`${(p.firstName || '')[0] || ''}${(p.lastName || '')[0] || ''}`, px + 10, py + 10.5) - }) - if (scale > LOD_LABEL_FADE_OUT) { - ctx.fillStyle = COLORS.text - ctx.font = CARD_FONT - ctx.textAlign = 'left' - ctx.textBaseline = 'middle' - ctx.fillText(node._data.label ? t('Famille {name}', { name: node._data.label }) : t('Famille'), cx - w / 2 + 72, cy - 8) - ctx.fillStyle = '#93402A' - ctx.font = CARD_SMALL - ctx.fillText(t('{n} personnes', { n: node._data.count }), cx - w / 2 + 72, cy + 10) - } - ctx.restore() - const target = posMap.get(node._data.targetId) - if (target && alpha > 0.5) renvoiHitAreas.push({ x0: cx - w / 2, y0: cy - h / 2, x1: cx + w / 2, y1: cy + h / 2, targetX: target.cx, targetY: target.cy }) -} - -// ============================================================ -// Le nom de la famille où l'on est, écrit en grand à l'écran (en haut à gauche) : celle dont le bloc contient -// le centre de la vue, sinon la plus proche. Coordonnées d'écran, lisible à tout zoom. -// ============================================================ -export function familyAt(families, view) { - if (!families?.length || !view) return null - const cx = (view.x0 + view.x1) / 2, cy = (view.y0 + view.y1) / 2 - const dist = (f) => Math.hypot(Math.max(f.bbox.x0 - cx, 0, cx - f.bbox.x1), Math.max(f.bbox.y0 - cy, 0, cy - f.bbox.y1)) - return families.reduce((best, f) => (f.bbox && (!best || dist(f) < dist(best)) ? f : best), null) -} -export function drawFamilyBanner(ctx, family) { - if (!family) return - ctx.save() - ctx.font = '500 30px "Newsreader", Georgia, serif' - ctx.textAlign = 'left' - ctx.textBaseline = 'alphabetic' - const title = family.label ? t('Famille {name}', { name: family.label }) : t('Famille') - // Un voile de la couleur du fond, pour rester lisible quand l'arbre passe dessous au dézoom - const w = ctx.measureText(title).width + 56 - const plate = ctx.createLinearGradient(0, 0, w + 60, 0) - plate.addColorStop(0, 'rgba(251, 250, 247, 0.92)') - plate.addColorStop(1, 'rgba(251, 250, 247, 0)') - ctx.fillStyle = plate - ctx.fillRect(0, 0, w + 60, 100) - ctx.fillStyle = COLORS.text - ctx.fillText(title, 28, 56) - ctx.fillStyle = COLORS.textLight - ctx.font = '400 13px "DM Sans", system-ui, sans-serif' - ctx.fillText(t('{n} personnes', { n: family.count }), 29, 78) - ctx.restore() -} - -// ============================================================ -// Carte des familles (maquette J, 19/10). Passé un seuil de dézoom, l'arbre laisse la place à la carte : -// chaque famille est un bloc (nom, portraits, nombre), les blocs se rangent côte à côte au milieu de l'écran, -// la famille principale au centre, les familles par alliance de leur côté, et chaque mariage entre familles -// est un trait de bloc à bloc avec les deux prénoms. Coordonnées d'écran : la carte ne bouge plus avec le zoom. -// ============================================================ -export function drawFamilyMap(ctx, families, cssW, cssH) { - if (!families?.length) return - const W = 290, H = 112, GAPX = 170 - const main = families.find((f) => f.id === 'main') || families[0] - const left = families.filter((f) => f !== main && f.side < 0) - const right = families.filter((f) => f !== main && !(f.side < 0)) - const cy = cssH / 2 - // La famille principale au milieu ; de chaque côté, les familles par alliance en colonne, chacune reliée - // en droite ligne au bloc principal. Aucun trait ne passe derrière un bloc. - const ROWY = H + 44 - const posOf = new Map([[main.id, { x: 0, y: cy }]]) - const place = (list, dir) => list.forEach((f, k) => posOf.set(f.id, { x: dir * (W + GAPX), y: cy + (k - (list.length - 1) / 2) * ROWY })) - place(left, -1); place(right, 1) - // Le groupe entier est centré à l'écran et réduit s'il déborde - const xs = [...posOf.values()].map((c) => c.x) - const x0 = Math.min(...xs) - W / 2, x1 = Math.max(...xs) + W / 2 - const ys = [...posOf.values()].map((c) => c.y) - const fit = Math.min(1, (cssW - 48) / (x1 - x0), (cssH - 160) / (Math.max(...ys) - Math.min(...ys) + H)) - ctx.save() - ctx.translate(cssW / 2, cy) - ctx.scale(fit, fit) - ctx.translate(-(x0 + x1) / 2, -cy) - ctx.lineCap = 'round' - const labels = [] - for (const f of families) for (const l of (f.links || [])) { - const g = families.find((x) => x.id === l.to) - const a = posOf.get(f.id), b = g && posOf.get(g.id) - if (!a || !b) continue - const dx = b.x - a.x, dy = b.y - a.y, len = Math.hypot(dx, dy) || 1 - const ux = dx / len, uy = dy / len - const clip = (c, tx, ty) => { const kx = Math.abs(tx) > 1e-6 ? (W / 2) / Math.abs(tx) : Infinity; const ky = Math.abs(ty) > 1e-6 ? (H / 2) / Math.abs(ty) : Infinity; const k = Math.min(kx, ky); return { x: c.x + tx * k, y: c.y + ty * k } } - const p1 = clip(a, ux, uy), p2 = clip(b, -ux, -uy) - ctx.strokeStyle = FIL.color - ctx.lineWidth = 1.6 - ctx.beginPath(); ctx.moveTo(p1.x, p1.y); ctx.lineTo(p2.x, p2.y); ctx.stroke() - if (l.label) labels.push({ text: l.label, x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 }) - } - for (const f of families) { - const c = posOf.get(f.id) - if (!c) continue - ctx.fillStyle = '#FFFFFF' - ctx.strokeStyle = '#E3DED6' - ctx.lineWidth = 1 - ctx.beginPath(); ctx.roundRect(c.x - W / 2, c.y - H / 2, W, H, 18); ctx.fill(); ctx.stroke() - ;(f.portraits || []).forEach((p, i) => { - const px = c.x - W / 2 + 24 + (i % 3) * 30, py = c.y - 16 + Math.floor(i / 3) * 30 - ctx.fillStyle = '#F2EFEA'; ctx.strokeStyle = '#E3DED6'; ctx.lineWidth = 0.8 - ctx.beginPath(); ctx.roundRect(px - 11, py - 11, 22, 22, 4); ctx.fill(); ctx.stroke() - ctx.fillStyle = COLORS.textLight - ctx.font = '400 9px "Newsreader", Georgia, serif' - ctx.textAlign = 'center'; ctx.textBaseline = 'middle' - ctx.fillText(`${(p.firstName || '')[0] || ''}${(p.lastName || '')[0] || ''}`, px, py + 0.5) - }) - ctx.fillStyle = COLORS.text - ctx.font = '500 18px "Newsreader", Georgia, serif' - ctx.textAlign = 'left'; ctx.textBaseline = 'middle' - ctx.fillText(f.label ? t('Famille {name}', { name: f.label }) : t('Famille'), c.x - W / 2 + 118, c.y - 12) - ctx.fillStyle = '#93402A' - ctx.font = '400 12px "DM Sans", system-ui, sans-serif' - ctx.fillText(t('{n} personnes', { n: f.count }), c.x - W / 2 + 118, c.y + 14) - } - // Les prénoms du mariage, sur le trait, au-dessus des blocs - ctx.font = '400 11px "DM Sans", system-ui, sans-serif' - ctx.textAlign = 'center'; ctx.textBaseline = 'middle' - for (const l of labels) { - const w = ctx.measureText(l.text).width + 12 - ctx.fillStyle = '#FBFAF7' - ctx.beginPath(); ctx.roundRect(l.x - w / 2, l.y - 9, w, 18, 9); ctx.fill() - ctx.fillStyle = COLORS.textLight - ctx.fillText(l.text, l.x, l.y + 0.5) - } - ctx.restore() -} - // Après drawNodes : les pastilles passent au-dessus des portraits et des souvenirs export function drawRenvoiPills(ctx) { renvoiPills.forEach(p => drawRenvoiPill(ctx, p)) @@ -442,6 +264,7 @@ export function drawRenvoiPills(ctx) { export function drawFiliations(ctx, edges, posMap, nodeMap, nodeRandomData, entrance, entranceActive, elapsed, view = null) { renvoiHitAreas.length = 0 renvoiPills.length = 0 + familyHitAreas.length = 0 if (!edges) return const sibships = new Map() @@ -837,6 +660,25 @@ function drawPersonNode(ctx, node, pos, nodeProgress, { ctx.fillText(years, 0, hasNickname ? 31 : 15) } + // Sa famille est un onglet : un badge le dit, un clic l'ouvre + if (withDetail && node._familyTab) { + const tab = node._familyTab + const text = `${tab.label ? t('Famille {name}', { name: tab.label }) : t('Famille')} · ${tab.count} ›` + ctx.font = '500 10.5px "DM Sans", system-ui, sans-serif' + const w = ctx.measureText(text).width + 18, h = 18 + const by = (hasNickname ? 31 : 15) + 21 + ctx.fillStyle = '#FCF3EF' + ctx.strokeStyle = '#EDB6A4' + ctx.lineWidth = 0.9 + ctx.beginPath() + ctx.roundRect(-w / 2, by - h / 2, w, h, h / 2) + ctx.fill() + ctx.stroke() + ctx.fillStyle = '#93402A' + ctx.fillText(text, 0, by + 0.5) + if (nodeProgress * labelAlpha > 0.5) familyHitAreas.push({ x0: cx - w / 2, y0: cy + labelOffsetY + by - h / 2, x1: cx + w / 2, y1: cy + labelOffsetY + by + h / 2, anchorId: tab.anchorId }) + } + ctx.restore() } @@ -1234,8 +1076,6 @@ export function drawNodes(ctx, layoutData, posMap, entrance, entranceActive, ela if (node._type === 'person') { drawPersonNode(ctx, node, pos, nodeProgress, renderState) - } else if (node._type === 'family') { - drawFamilyCard(ctx, node, pos, posMap, nodeProgress, view) } else if (node._type === 'union') { ctx.globalAlpha = nodeProgress ctx.fillStyle = FIL.dot diff --git a/frontend/src/components/galaxy/useGalaxyInteractions.js b/frontend/src/components/galaxy/useGalaxyInteractions.js index f149fa9..9e3644c 100644 --- a/frontend/src/components/galaxy/useGalaxyInteractions.js +++ b/frontend/src/components/galaxy/useGalaxyInteractions.js @@ -1,9 +1,10 @@ import { useRef, useCallback } from 'react' import { getPersonMedias } from '../../data/mockData' import { MAX_ORBIT_MEDIAS, ORBIT_MEDIA_SIZE } from './constants' -import { nodeRadius, renvoiHitAreas, photoPlaceholderHitAreas } from './renderers' +import { nodeRadius, renvoiHitAreas, familyHitAreas, photoPlaceholderHitAreas } from './renderers' const hitRenvoi = (x, y) => renvoiHitAreas.find(a => x >= a.x0 && x <= a.x1 && y >= a.y0 && y <= a.y1) +const hitFamily = (x, y) => familyHitAreas.find(a => x >= a.x0 && x <= a.x1 && y >= a.y0 && y <= a.y1) const hitPhotoPlaceholder = (x, y) => photoPlaceholderHitAreas.find(a => Math.hypot(x - a.cx, y - a.cy) < a.r) import { getEntranceProgress } from './utils' @@ -22,7 +23,7 @@ export function useGalaxyInteractions({ canvasRef, transformRef, targetTransformRef, layoutDataRef, nodeRandomDataRef, entranceRef, hoveredNodeIdRef, hoveredMediaKeyRef, mouseWorldPosRef, - getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick = null, + getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick = null, onOpenFamily = null, annotationHandlers, minScale = 0.2, maxScale = 4, @@ -138,7 +139,7 @@ export function useGalaxyInteractions({ break } } - if (!isOverClickable && hitRenvoi(mouseWorldPosRef.current.x, mouseWorldPosRef.current.y)) isOverClickable = true + if (!isOverClickable && (hitRenvoi(mouseWorldPosRef.current.x, mouseWorldPosRef.current.y) || hitFamily(mouseWorldPosRef.current.x, mouseWorldPosRef.current.y))) isOverClickable = true if (!isOverClickable && hitPhotoPlaceholder(mouseWorldPosRef.current.x, mouseWorldPosRef.current.y)) isOverClickable = true hoveredNodeIdRef.current = newHoveredNode hoveredMediaKeyRef.current = newHoveredMedia @@ -284,6 +285,10 @@ export function useGalaxyInteractions({ } } + // Badge de famille : ouvre l'onglet de cette famille + const fam = hitFamily(clickX, clickY) + if (fam) { onOpenFamily?.(fam.anchorId); return } + // Renvoi : on glisse vers l'autre extrémité (parents ou enfant), sans dézoomer en dessous de la lecture des prénoms const renvoi = hitRenvoi(clickX, clickY) if (renvoi) { @@ -295,7 +300,7 @@ export function useGalaxyInteractions({ y: rect2.height / 2 - renvoi.targetY * scale, } } - }, [canvasRef, transformRef, targetTransformRef, layoutDataRef, nodeRandomDataRef, entranceRef, getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick, annotationHandlers]) + }, [canvasRef, transformRef, targetTransformRef, layoutDataRef, nodeRandomDataRef, entranceRef, getAnimatedPos, onPersonSelect, onMediaSelect, onPhotoPlaceholderClick, onOpenFamily, annotationHandlers]) return { isDragging, isZooming, zoomTimeoutRef, hasDragged, diff --git a/frontend/src/i18n/en/arbre.js b/frontend/src/i18n/en/arbre.js index 27f43a8..5b8273e 100644 --- a/frontend/src/i18n/en/arbre.js +++ b/frontend/src/i18n/en/arbre.js @@ -2,6 +2,7 @@ export default { 'Famille {name}': 'The {name} family', 'Famille': 'Family', + 'Familles': 'Families', // Arbre sur canvas (components/galaxy/renderers.js) 'Voir les parents': 'See parents', 'Voir {firstName}': 'See {firstName}',