diff --git a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx
index 10a6e47..204678b 100644
--- a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx
+++ b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx
@@ -21,57 +21,74 @@ export function ComplexFamilyTree(p: {
if (!container) return;
const store = f3.createStore({
- data: treeToF3Data(p.tree, p.isUp),
- node_separation: 250,
- level_separation: 150,
- }),
- view = f3.d3AnimationView({
- store,
- cont: container,
- }),
- Card = f3.elements.Card({
- store,
- svg: view.svg,
- card_dim: {
- w: 210,
- h: 118,
- text_x: 5,
- text_y: 70,
- img_w: 60,
- img_h: 60,
- img_x: 5,
- img_y: 5,
+ data: treeToF3Data(p.tree, p.isUp),
+ node_separation: 250,
+ level_separation: 150,
+ });
+ const view = f3.d3AnimationView({
+ store,
+ cont: container,
+ });
+ const Card = f3.elements.Card({
+ store,
+ svg: view.svg,
+ card_dim: {
+ w: 210,
+ h: 118,
+ text_x: 5,
+ text_y: 70,
+ img_w: 60,
+ img_h: 60,
+ img_x: 5,
+ img_y: 5,
+ },
+ card_display: [
+ (d) =>
+ `${d.data.first_name || ""} ${d.data.last_name || ""} ${
+ d.data.dead ? "✝" : ""
+ }`,
+ (d) => {
+ let birthDeath = [];
+ if (d.data.birthday) birthDeath.push(d.data.birthday);
+ if (d.data.deathday) birthDeath.push(d.data.deathday);
+
+ let s = birthDeath.join(" -> ");
+
+ if (d.data.wedding_state || d.data.dateOfWedding) {
+ let weddingInfo = [];
+ if (d.data.wedding_state) weddingInfo.push(d.data.wedding_state);
+ if (d.data.dateOfWedding)
+ weddingInfo.push("Mariage : " + d.data.dateOfWedding);
+ s += ` ${weddingInfo.join(
+ " - "
+ )}`;
+ }
+
+ return s;
},
- card_display: [
- (d) =>
- `${d.data.first_name || ""} ${d.data.last_name || ""} ${
- d.data.dead ? "✝" : ""
- }`,
- (d) => {
- let birthDeath = [];
- if (d.data.birthday) birthDeath.push(d.data.birthday);
- if (d.data.deathday) birthDeath.push(d.data.deathday);
+ ],
+ mini_tree: true,
+ link_break: false,
+ });
- let s = birthDeath.join(" -> ");
+ // Patch generated card
+ const PatchedCard: f3.F3CardBuilder = (p) => {
+ const res = Card(p);
- if (d.data.wedding_state || d.data.dateOfWedding) {
- let weddingInfo = [];
- if (d.data.wedding_state) weddingInfo.push(d.data.wedding_state);
- if (d.data.dateOfWedding)
- weddingInfo.push("Mariage : " + d.data.dateOfWedding);
- s += ` ${weddingInfo.join(
- " - "
- )}`;
- }
+ // Patch card colors for PDF export
+ res
+ .querySelector(".card-male")
+ ?.querySelector(".card-body-rect")
+ ?.setAttribute("fill", "#add8e6");
+ res
+ .querySelector(".card-female")
+ ?.querySelector(".card-body-rect")
+ ?.setAttribute("fill", "#ffb6c1");
- return s;
- },
- ],
- mini_tree: true,
- link_break: false,
- });
+ return res;
+ };
- view.setCard(Card);
+ view.setCard(PatchedCard);
store.setOnUpdate((props) => view.update(props || {}));
store.update.tree({ initial: false, transition_time: 0 });
};
@@ -104,11 +121,6 @@ export function ComplexFamilyTree(p: {
` string)[];
- }) => (p: { node; d }) => HTMLElement;
+ }) => F3CardBuilder;
};
+
+ type F3CardBuilder = (p: { node; d }) => HTMLElement;
+
const elements: F3elements;
}