Skip to content

Commit 93a5f7b

Browse files
authored
Merge pull request #184 from l0drex/beta
v1.4
2 parents 3256628 + bf0518a commit 93a5f7b

29 files changed

+13698
-10511
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ updates:
88
- package-ecosystem: "npm" # See documentation for possible values
99
directory: "/" # Location of package manifests
1010
schedule:
11-
interval: "weekly"
11+
interval: "monthly"
1212
labels:
1313
- "update"
14+
target-branch: "beta"

package-lock.json

Lines changed: 11868 additions & 10176 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"@types/node": "^20.2.5",
3030
"@types/react": "^18.2.7",
3131
"@types/react-dom": "^18.2.4",
32+
"@visx/axis": "^3.1.0",
33+
"@visx/geo": "^3.0.0",
34+
"@visx/shape": "^3.0.0",
35+
"@visx/stats": "^3.0.0",
36+
"@visx/visx": "^3.1.2",
3237
"d3": "7.6.1",
3338
"gedcomx-js": "^2.8.0",
3439
"react": "^18.1.0",

src/App.css

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
@import url('https://fonts.googleapis.com/css2?family=Nunito&display=swap');
22

3+
:root {
4+
background: var(--background-lower);
5+
color: var(--foreground);
6+
font-family: "Nunito", sans-serif;
7+
}
8+
39
#root {
410
height: 100%;
511
width: 100%;
@@ -10,9 +16,6 @@
1016
grid-template-columns: 1fr;
1117
overflow: auto;
1218

13-
background: var(--background-lower);
14-
font-family: "Nunito", sans-serif;
15-
1619
grid-template-areas:
1720
"header"
1821
"main"
@@ -29,16 +32,83 @@ main {
2932
}
3033

3134
main > * {
32-
background: var(--background);
3335
margin: 1rem auto 0;
3436
box-sizing: border-box;
35-
border-radius: .5rem;
3637
}
3738

3839
main > :first-child {
3940
margin-top: 0;
4041
}
4142

43+
article {
44+
border-radius: 1rem;
45+
background: var(--background);
46+
}
47+
48+
aside {
49+
overflow-y: scroll;
50+
overflow-x: hidden;
51+
display: flex;
52+
gap: 1rem;
53+
flex-flow: row;
54+
max-width: 100vw;
55+
flex-wrap: wrap;
56+
grid-area: sidebar;
57+
max-height: 30vh;
58+
padding: 0 1rem;
59+
}
60+
61+
aside > * {
62+
flex: 1 1 0;
63+
}
64+
65+
aside .title {
66+
flex-basis: 100%;
67+
}
68+
69+
aside .title :first-child {
70+
margin-top: 0;
71+
}
72+
73+
aside .title :last-child {
74+
margin-bottom: 0;
75+
}
76+
77+
aside h1, aside article h1 {
78+
font-size: 1.5rem;
79+
}
80+
81+
aside .title > h1, aside .title > h2 {
82+
text-align: center;
83+
}
84+
85+
aside .title h2 {
86+
font-weight: normal;
87+
}
88+
89+
@media (orientation: landscape) {
90+
aside {
91+
flex-flow: column;
92+
padding-right: 0;
93+
max-height: unset;
94+
}
95+
96+
aside > * {
97+
flex-grow: 0;
98+
}
99+
100+
aside .title {
101+
flex-basis: 0;
102+
}
103+
}
104+
105+
aside > article {
106+
padding: 1rem;
107+
box-sizing: border-box;
108+
box-shadow: inset 0 .25rem .25rem rgba(0, 0, 0, .33);
109+
flex-basis: 200px;
110+
}
111+
42112
footer {
43113
color: var(--foreground-secondary);
44114
text-align: left;
@@ -105,3 +175,19 @@ li:not(:last-child) {
105175
margin-right: 1rem;
106176
}
107177
}
178+
179+
@media print {
180+
#root.sidebar-visible {
181+
gap: 0;
182+
}
183+
184+
aside {
185+
border: solid 1pt;
186+
}
187+
188+
header, footer, #view-all {
189+
height: 0;
190+
width: 0;
191+
visibility: hidden;
192+
}
193+
}

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import {strings} from "./main";
44
import View from "./components/View";
55
import {BrowserRouter, Route, Routes} from "react-router-dom";
66
import {Home, Imprint} from "./components/Home";
7+
import Statistics from "./components/Statistics";
78

89
function App() {
910
return <BrowserRouter basename={"family-tree"}>
1011
<Routes>
1112
<Route path="/" element={<Home/>}/>
1213
<Route path="/view" element={<View/>}/>
1314
<Route path="/imprint" element={<Imprint/>}/>
15+
<Route path="/stats" element={<Statistics/>}/>
1416
</Routes>
1517
<footer>
1618
<span>

src/backend/Fact.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {PersonFactTypes} from "./gedcomx-enums";
55
test("toString works", () => {
66
config.browserLang = "en";
77
let fact = new GedcomX.Fact().setType(PersonFactTypes.Birth);
8-
expect(fact.toString()).toBe("born")
8+
expect(fact.toString()).toBe("Birth")
99

1010
fact.setDate(new GedcomX.Date().setFormal("+2022-01-25T06:55"))
11-
expect(fact.toString()).toBe("born on 01/25/2022 at 06:55 AM")
11+
expect(fact.toString()).toBe("Birth on 01/25/2022 at 06:55 AM")
1212
})

src/backend/ModelGraph.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ import GedcomX, {setReferenceAge} from "./gedcomx-extensions";
22
import viewGraph, {ViewMode} from "./ViewGraph";
33
import config from "../config";
44
import {PersonFactTypes} from "./gedcomx-enums";
5+
import {filterLang} from "../main";
56

67
let lastViewGraphBuildParams: {id: string, view: ViewMode | string}
78

89
class ModelGraph extends GedcomX.Root {
910
constructor(data) {
1011
super(data)
12+
13+
// localize
14+
this.persons = (this.persons ?? []).filter(filterLang);
15+
this.relationships = (this.relationships ?? []).filter(filterLang);
16+
this.events = (this.events ?? []).filter(filterLang);
17+
this.documents = (this.documents ?? []).filter(filterLang);
18+
this.places = (this.places ?? []).filter(filterLang);
19+
1120
if (!data || data.persons.length < 0 || data.relationships.length < 0) {
1221
throw new Error("The calculated graph is empty! Please check if your files are empty. If not, please file a bug report!");
1322
}
@@ -24,7 +33,14 @@ class ModelGraph extends GedcomX.Root {
2433
}
2534

2635
getSourceDescriptionById(id: string): GedcomX.SourceDescription {
27-
return this.getSourceDescriptions().find(d => d.getId() === id);
36+
return this.getSourceDescriptions().find(d => d.id === id);
37+
}
38+
39+
getAgentById(id: string | GedcomX.ResourceReference): GedcomX.Agent {
40+
if (id instanceof GedcomX.ResourceReference) {
41+
id = id.getResource().substring(1);
42+
}
43+
return this.agents.find(a => (id as string) in a.getIdentifiers().getValues());
2844
}
2945

3046
getPersonByName = (name: string): GedcomX.Person => {
@@ -195,12 +211,12 @@ class ModelGraph extends GedcomX.Root {
195211
private setAgeGen0 = (startPerson: GedcomX.Person) => {
196212
let personWithKnownAge = this.persons
197213
.filter(p => {
198-
let generationStartFacts = startPerson.getFactsByType(PersonFactTypes.Generation);
214+
let generationStartFacts = startPerson.getFactsByType(PersonFactTypes.GenerationNumber);
199215
if (generationStartFacts.length < 1) {
200216
return false;
201217
}
202218
let generationStart = generationStartFacts[0].getValue();
203-
let generationPFacts = p.getFactsByType(PersonFactTypes.Generation)
219+
let generationPFacts = p.getFactsByType(PersonFactTypes.GenerationNumber)
204220
if (generationPFacts.length < 1) {
205221
return false;
206222
}
@@ -215,7 +231,7 @@ class ModelGraph extends GedcomX.Root {
215231
}
216232
setReferenceAge(personWithKnownAge.getAgeToday(),
217233
// get generation from generation fact
218-
Number(personWithKnownAge.getFactsByType(PersonFactTypes.Generation)[0].getValue()));
234+
Number(personWithKnownAge.getFactsByType(PersonFactTypes.GenerationNumber)[0].getValue()));
219235
}
220236

221237
private getAncestors(person: GedcomX.Person): GedcomX.Person[] {

src/backend/Person.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import GedcomX, {setReferenceAge} from "./gedcomx-extensions";
2-
import config from "../config";
32
import {PersonFactTypes} from "./gedcomx-enums";
3+
import {strings} from "../main";
44

55
test("Age calculated correct", () => {
66
setReferenceAge(0, 0);
77
let person = new GedcomX.Person()
88
.addFact(new GedcomX.Fact()
9-
.setType(PersonFactTypes.Generation)
9+
.setType(PersonFactTypes.GenerationNumber)
1010
.setValue(0));
1111
expect(person.getAgeToday()).toBe(0);
1212

@@ -41,9 +41,11 @@ test("get full name returns the correct name", () => {
4141
.addNameForm(new GedcomX.NameForm().setFullText("Maximilian Mustermann")))
4242
expect(person.getFullName()).toBe("Maximilian Mustermann");
4343

44-
config.browserLang = "en";
44+
45+
strings.setLanguage("en");
46+
4547
person.addName(new GedcomX.Name()
46-
.setLang("en")
48+
.setLang(strings.getLanguage())
4749
.addNameForm(new GedcomX.NameForm().setFullText("John Doe")));
4850
expect(person.getFullName()).toBe("John Doe");
4951

0 commit comments

Comments
 (0)