diff --git a/src/components/App.tsx b/src/components/App.tsx index 76fe11f..6a36091 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -29,6 +29,7 @@ function App(props: AppProps) { const [split, setSplitValue] = useCache('split', !!props.split); const [hidePersonCode, setHideCode] = useCache('hideCode', false); + const [hidePersonIg, setHideIg] = useCache('hideCode', false); const [editMode, setEditModeValue] = useState(false); const [modalPerson, setModalPerson] = useState(null as Person | null); @@ -123,6 +124,7 @@ function App(props: AppProps) { split, editMode, hidePersonCode, + hidePersonIg, treeMap, setTreesValue, upsertPerson, @@ -145,12 +147,23 @@ function App(props: AppProps) { setHideCode(!hidePersonCode)} /> + + + setHideIg(!hidePersonIg)} + /> + diff --git a/src/components/AppContext.tsx b/src/components/AppContext.tsx index 44e10b9..9a933f6 100644 --- a/src/components/AppContext.tsx +++ b/src/components/AppContext.tsx @@ -5,6 +5,7 @@ interface AppContextValue { split: boolean; editMode: boolean; hidePersonCode: boolean; + hidePersonIg: boolean; setTreesValue: (ps: Person[]) => void; upsertPerson: (p: Person) => void; deletePerson: (p: Person) => void; @@ -15,6 +16,7 @@ const AppContext = createContext({ split: false, editMode: false, hidePersonCode: false, + hidePersonIg: false, setTreesValue: () => {}, upsertPerson: () => {}, deletePerson: () => {}, diff --git a/src/components/Family.tsx b/src/components/Family.tsx index 4fc0203..1c62516 100644 --- a/src/components/Family.tsx +++ b/src/components/Family.tsx @@ -3,7 +3,7 @@ import { Person } from '../family.interface'; import AppContext from './AppContext'; import FamilyGrid from './FamilyGrid'; import FamilyDiagram from './FamilyDiagram'; -import { explodeTrees } from '../family.util'; +import { explodeTrees, idAsNickName } from '../family.util'; interface FamilyProps { trees: Person[]; @@ -24,7 +24,9 @@ function SplitFamilies({ trees, ...props }: FamilyProps) { {people.map(tree => (
-

{tree.name ?? tree.id} Family

+

+ {tree.name ?? idAsNickName(tree.id)} Family +

diff --git a/src/components/FamilyDiagram.tsx b/src/components/FamilyDiagram.tsx index 30dc106..348f91a 100644 --- a/src/components/FamilyDiagram.tsx +++ b/src/components/FamilyDiagram.tsx @@ -5,6 +5,13 @@ import * as go from 'gojs'; import { isEqual, cloneDeep } from 'lodash'; import GenogramLayout from '../GenogramLayout'; +const SLASH_COLOR = '#d4071c'; // red +const MALE_COLOR = '#c5ecff'; // Aesthetic Pastel non photo blue +const FEMALE_COLOR = '#fee6ff'; // Aesthetic Pastel pink lavender +const SHAPE_LINE_COLOR = '#a1a1a1'; +const MARRIAGE_LINE_COLOR = '#5d8cc1'; // blue +const CHILD_LINE_COLOR = '#919191'; + interface FamilyDiagramProps { trees: Person[]; depth?: number; @@ -70,7 +77,7 @@ class DiagramUtil { // determine the color for each attribute shape function attrFill(a: String) { - if (a === 'S') return '#d4071c'; // red + if (a === 'S') return SLASH_COLOR; // red return 'transparent'; } @@ -90,17 +97,16 @@ class DiagramUtil { locationSpot: go.Spot.Center, locationObjectName: 'ICON', selectionObjectName: 'ICON', + selectable: false, }, - new go.Binding('opacity', 'hide', h => (h ? 0 : 1)), - new go.Binding('pickable', 'hide', h => !h), $(go.Panel, { name: 'ICON' }, $(go.Shape, 'Square', { width: 40, height: 40, strokeWidth: 2, - fill: 'white', - stroke: '#919191', + fill: MALE_COLOR, + stroke: SHAPE_LINE_COLOR, portId: '', }), $(go.Panel, @@ -121,7 +127,6 @@ class DiagramUtil { { textAlign: 'center', maxSize: new go.Size(80, NaN), - background: 'rgba(255,255,255,0.5)', }, new go.Binding('text', 'name') ) @@ -135,17 +140,16 @@ class DiagramUtil { locationSpot: go.Spot.Center, locationObjectName: 'ICON', selectionObjectName: 'ICON', + selectable: false, }, - new go.Binding('opacity', 'hide', h => (h ? 0 : 1)), - new go.Binding('pickable', 'hide', h => !h), $(go.Panel, { name: 'ICON' }, $(go.Shape, 'Circle', { width: 40, height: 40, strokeWidth: 2, - fill: 'white', - stroke: '#a1a1a1', + fill: FEMALE_COLOR, + stroke: SHAPE_LINE_COLOR, portId: '', }), $(go.Panel, @@ -166,7 +170,6 @@ class DiagramUtil { { textAlign: 'center', maxSize: new go.Size(80, NaN), - background: 'rgba(255,255,255,0.5)', }, new go.Binding('text', 'name') ) @@ -192,7 +195,7 @@ class DiagramUtil { layerName: 'Background', selectable: false, }, - $(go.Shape, { stroke: 'gray', strokeWidth: 2 }) + $(go.Shape, { stroke: CHILD_LINE_COLOR, strokeWidth: 2 }) ); myDiagram.linkTemplateMap.add( @@ -208,7 +211,7 @@ class DiagramUtil { isTreeLink: false, layerName: 'Background', }, - $(go.Shape, { strokeWidth: 2.5, stroke: '#5d8cc1' /* blue */ }) + $(go.Shape, { strokeWidth: 2.5, stroke: MARRIAGE_LINE_COLOR }) ) ); diff --git a/src/components/FamilyGrid.tsx b/src/components/FamilyGrid.tsx index 7e94038..296d728 100644 --- a/src/components/FamilyGrid.tsx +++ b/src/components/FamilyGrid.tsx @@ -1,7 +1,7 @@ import { ChangeEvent, useContext } from 'react'; import { Input, Table } from 'reactstrap'; import { Person } from '../family.interface'; -import { explodeTrees } from '../family.util'; +import { explodeTrees, idAsNickName } from '../family.util'; import AppContext from './AppContext'; interface FamilyGridProps { @@ -9,7 +9,7 @@ interface FamilyGridProps { } export default function FamilyGrid({ trees }: FamilyGridProps) { - const { hidePersonCode } = useContext(AppContext); + const { hidePersonCode, hidePersonIg } = useContext(AppContext); return ( @@ -23,7 +23,9 @@ export default function FamilyGrid({ trees }: FamilyGridProps) { - + @@ -58,8 +60,10 @@ function FamilyRows({ person, ...props }: PersonRowProps) { } function PersonRow({ person }: PersonRowProps) { - const { editMode, hidePersonCode, upsertPerson } = useContext(AppContext); - const name = person.name || person.id; + const { editMode, hidePersonCode, hidePersonIg, upsertPerson } = + useContext(AppContext); + const nickName = idAsNickName(person.id); + const name = person.name || nickName; const updatePerson = function (e: ChangeEvent, key: string) { upsertPerson({ ...person, [key]: e.target.value }); @@ -87,7 +91,7 @@ function PersonRow({ person }: PersonRowProps) { /> {name} - {person.name && ({person.id})} + {person.name && ({nickName})} -
Birthdate Phone AddressIG
@@ -126,7 +130,7 @@ function PersonRow({ person }: PersonRowProps) { /> {person.address} +