diff --git a/geneit_app/src/utils/string_utils.ts b/geneit_app/src/utils/string_utils.ts new file mode 100644 index 0000000..31bbb1f --- /dev/null +++ b/geneit_app/src/utils/string_utils.ts @@ -0,0 +1,8 @@ +export function getAllIndexes(s: string, val: string) { + var indexes = [], + i = -1; + while ((i = s.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; +} diff --git a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx index e1106f0..9d1e7f1 100644 --- a/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx +++ b/geneit_app/src/widgets/complex_family_tree/ComplexFamilyTree.tsx @@ -9,6 +9,7 @@ import { IconButton } from "@mui/material"; import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf"; import { jsPDF } from "jspdf"; import "svg2pdf.js"; +import { getAllIndexes } from "../../utils/string_utils"; export function ComplexFamilyTree(p: { tree: FamilyTreeNode; @@ -112,6 +113,21 @@ export function ComplexFamilyTree(p: { dstSVG = dstSVG.replaceAll(`>UNKNOWN<`, `fill="#000">INCONNU<`); + let womanTiles = getAllIndexes(dstSVG, "card-female"); + for (const i of womanTiles) { + dstSVG = + dstSVG.substring(0, i) + + dstSVG.substring(i + 1).replace(`fill="white"`, `fill="#ffb6c1"`); + } + + let manTiles = getAllIndexes(dstSVG, "card-male"); + for (const i of manTiles) { + dstSVG = + dstSVG.substring(0, i) + + dstSVG.substring(i + 1).replace(`fill="white"`, `fill="#add8e6"`); + } + + //navigator.clipboard.writeText(dstSVG); target.innerHTML = dstSVG; await doc.svg(target, {