Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DH Code review #2

Open
wants to merge 766 commits into
base: empty
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
766 commits
Select commit Hold shift + click to select a range
377045f
Update cultural-property.md
jhimpele Jun 7, 2023
6445bd5
Update delaware-nation-in-oklahoma.md
jhimpele Jun 7, 2023
f7483e5
Update delaware-valley.md
jhimpele Jun 7, 2023
c793802
Update departure.md
jhimpele Jun 7, 2023
c93c45d
Update dutch-settle.md
jhimpele Jun 7, 2023
07d6e6b
Update europeans.md
jhimpele Jun 7, 2023
80d5198
Update exodus.md
jhimpele Jun 7, 2023
20dc65f
Rename wooley.md to woolley.md
jhimpele Jun 7, 2023
ac8e444
Update woolley.md
jhimpele Jun 7, 2023
85b3786
Update gnadenhutten-massacre.md
jhimpele Jun 7, 2023
11aa65f
Update greenville-treaty.md
jhimpele Jun 7, 2023
698fd15
Update guardian.md
jhimpele Jun 7, 2023
65be7c7
Update kansas.md
jhimpele Jun 7, 2023
6a2ba64
Update kansas.md
jhimpele Jun 7, 2023
639af6f
Update land-donated.md
jhimpele Jun 7, 2023
9aae6de
Update land-governance.md
jhimpele Jun 7, 2023
2c701c3
Update land-rights.md
jhimpele Jun 7, 2023
d10d2cc
Update land-seizure.md
jhimpele Jun 7, 2023
f58ee3e
Update and rename land-seizure.md to walking deceit.md
jhimpele Jun 7, 2023
6eb36f3
Update lawsuit.md
jhimpele Jun 7, 2023
bca691b
Update and rename lawsuit.md to walking_lawsuit.md
jhimpele Jun 7, 2023
756e0f9
Update library-collections.md
jhimpele Jun 7, 2023
738d29c
Update library-recognitions.md
jhimpele Jun 7, 2023
292ec57
Update library-collections.md
jhimpele Jun 7, 2023
2ae2f80
Update lunaapahkiing.md
jhimpele Jun 7, 2023
188ac2d
Update matriculation.md
jhimpele Jun 7, 2023
7aff9a7
Update midwest-resettlement.md
jhimpele Jun 7, 2023
4f6670e
Update minisink.md
jhimpele Jun 7, 2023
4ea36d8
Update munsee-names.md
jhimpele Jun 7, 2023
d1f11dd
Update munsee-three-sisters-farm.md
jhimpele Jun 7, 2023
87ecde3
Update chief-mark-peters.md
jhimpele Jun 7, 2023
1502031
Update murder.md
jhimpele Jun 7, 2023
38f8a19
Update museum.md
jhimpele Jun 7, 2023
d3d9f12
Update museum.md
jhimpele Jun 7, 2023
ef5ee35
Update naisip-founded.md
jhimpele Jun 7, 2023
7934e8b
Update nassau-hall.md
jhimpele Jun 7, 2023
ef5883d
Update nj-nanticoke.md
jhimpele Jun 7, 2023
a7c353d
Update nj-purchase.md
jhimpele Jun 7, 2023
3d040c1
Update nuclear-princeton.md
jhimpele Jun 7, 2023
e423eb2
Update munsee-three-sisters-farm.md
jhimpele Jun 7, 2023
1e407bb
Update munsee-three-sisters-farm.md
jhimpele Jun 7, 2023
073ffae
Update nuclear-princeton.md
jhimpele Jun 7, 2023
0efe860
Update occupation.md
jhimpele Jun 7, 2023
ba3416b
Update ontario-munsee.md
jhimpele Jun 7, 2023
c391884
Update departure.md
jhimpele Jun 7, 2023
41ed86b
Update otterskin.md
jhimpele Jun 7, 2023
aeeabb3
Update and rename pecos.md to Trustee.md
jhimpele Jun 7, 2023
f480bc4
Update nassau-hall.md
jhimpele Jun 7, 2023
71995ee
Update B. Calvin.md
jhimpele Jun 7, 2023
6c9f8e2
Update storytelling.md
jhimpele Jun 7, 2023
aa12040
Update and rename tlingit-property.md to Tlingit-art
jhimpele Jun 7, 2023
bcbe604
Update unami-migration.md
jhimpele Jun 7, 2023
0b18862
Update us-indian-scholars.md
jhimpele Jun 7, 2023
67e255b
Update yong.md
jhimpele Jun 7, 2023
861df77
Update seneca.md
jhimpele Jun 7, 2023
3d52df2
Remove leaf Bartholomew Calvin per @jhimpele request
rlskoeser Jun 7, 2023
a714c9c
Update ramapough-lenape.md
jhimpele Jun 8, 2023
a7787ac
Update pontiac.md
jhimpele Jun 8, 2023
d13f120
Update smallpox.md
jhimpele Jun 8, 2023
5ec2b8e
Update complaints.md
jhimpele Jun 8, 2023
6fe48c0
Update resources.md
jhimpele Jun 8, 2023
e3f1935
Update munsee-three-sisters-farm.md
jhimpele Jun 8, 2023
53ea1c7
Update and rename indian-town.md to tribal_home.md
jhimpele Jun 8, 2023
7429e6b
Update tribal_home.md
jhimpele Jun 8, 2023
1fd02da
Update Easton redux.md
jhimpele Jun 8, 2023
90ad733
Update matriculation.md
jhimpele Jun 8, 2023
d378ead
Update matriculation.md
jhimpele Jun 8, 2023
97b2be9
Update matriculation.md
jhimpele Jun 8, 2023
ece457c
Update matriculation.md
jhimpele Jun 8, 2023
1c603da
Update col-morgan.md
jhimpele Jun 8, 2023
11e3bc8
Chief_son.md
jhimpele Jun 8, 2023
6240fe1
Update matriculation.md
jhimpele Jun 8, 2023
ed8a375
Update departure.md
jhimpele Jun 8, 2023
ed85b61
Rename B. Calvin.md to B_Calvin.md
jhimpele Jun 8, 2023
e0fa875
Update william-potter-ross.md
jhimpele Jun 8, 2023
91ce259
Update col-morgan.md
jhimpele Jun 8, 2023
53affe4
Update departure.md
jhimpele Jun 8, 2023
3ab7a2a
Update col-morgan.md
jhimpele Jun 8, 2023
dff5941
Update sheldon-jackson.md
jhimpele Jun 8, 2023
68ae4fd
Update cultural-property.md
jhimpele Jun 8, 2023
ed2c35f
Update otterskin.md
jhimpele Jun 8, 2023
01881c4
Update Easton redux.md
jhimpele Jun 8, 2023
eebb839
Update citizenship.md
jhimpele Jun 8, 2023
33b85dc
Update gnadenhutten-massacre.md
jhimpele Jun 8, 2023
a7b74eb
Update mannahatta.md
jhimpele Jun 8, 2023
4f9faea
Update emigration.md
jhimpele Jun 8, 2023
35e00d1
Update westward-migration.md
jhimpele Jun 8, 2023
d3cf02c
Update mannahatta.md
jhimpele Jun 8, 2023
85ae317
Update otterskin.md
jhimpele Jun 8, 2023
714d9ec
Update munsee-three-sisters-farm.md
jhimpele Jun 8, 2023
63f4c2f
Update brotherton-pact.md
jhimpele Jun 8, 2023
9a35546
Update brotherton-res.md
jhimpele Jun 8, 2023
db927ef
Update bethel-mission.md
jhimpele Jun 8, 2023
42a9915
Update brotherton-res.md
jhimpele Jun 8, 2023
cd5fe0c
Update B_Calvin.md
jhimpele Jun 8, 2023
b15b04c
Update nuclear-princeton.md
jhimpele Jun 8, 2023
195eb58
Update pres-edwards.md
jhimpele Jun 8, 2023
c67efb5
Update pres-edwards.md
jhimpele Jun 8, 2023
bac42f3
Update naisip-founded.md
jhimpele Jun 8, 2023
69125d9
Update filmmaking.md
jhimpele Jun 8, 2023
62e2c44
Update credits.md
jhimpele Jun 8, 2023
308c60e
Clean up malformed tag data
rlskoeser Jun 8, 2023
6c6857d
Update complaints.md
jhimpele Jun 8, 2023
694f5e8
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
17a7dad
Update dutch-princeton.md
jhimpele Jun 8, 2023
5930a9c
Update dutch-princeton.md
jhimpele Jun 8, 2023
50e4535
Update wm-penn.md
jhimpele Jun 8, 2023
7c8f365
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
440d4d0
Update wm-penn.md
jhimpele Jun 8, 2023
3dcb7dc
Update dutch-princeton.md
jhimpele Jun 8, 2023
5b9b5c1
Update equality.md
jhimpele Jun 8, 2023
b9f41e2
Update wm-penn.md
jhimpele Jun 8, 2023
3a2f022
Update Easton redux.md
jhimpele Jun 8, 2023
73355fc
Update brotherton-collapse.md
jhimpele Jun 8, 2023
13b5556
Update westward-migration.md
jhimpele Jun 8, 2023
7b13803
Update wisconsin-munsee.md
jhimpele Jun 8, 2023
be166ca
Update wisconsin-munsee.md
jhimpele Jun 8, 2023
cd79368
Update wisconsin-munsee.md
jhimpele Jun 8, 2023
12b8c04
Update occupation.md
jhimpele Jun 8, 2023
b96fe37
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
81012bc
Update brotherton-pact.md
jhimpele Jun 8, 2023
3bdb45f
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
db70015
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
6d07cec
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
a419fa2
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
840964e
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
1b8f639
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
aaa8b26
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
dddde44
Update shackamaxon-treaty.md
jhimpele Jun 8, 2023
7c70ed2
Update delaware-nation-in-oklahoma.md
jhimpele Jun 8, 2023
576a16a
Update delaware-nation-in-oklahoma.md
jhimpele Jun 8, 2023
eda40e0
Update chiefs.md
jhimpele Jun 8, 2023
d00f781
Update bethel-mission.md
jhimpele Jun 8, 2023
06ee706
Update nj-nanticoke.md
jhimpele Jun 8, 2023
bf63181
Update chiefs.md
jhimpele Jun 8, 2023
1060512
Update easton-signing.md
jhimpele Jun 8, 2023
837a18f
Update pontiac.md
jhimpele Jun 8, 2023
f08a2ff
Update easton-treaty.md
jhimpele Jun 8, 2023
de08be9
Update easton-treaty-signed.md
jhimpele Jun 8, 2023
8a1993a
Rename easton-signing.md to easton-treaty-signed.md
jhimpele Jun 8, 2023
db4cd45
Update delaware-valley.md
jhimpele Jun 8, 2023
fce0e0c
Update Easton redux.md
jhimpele Jun 8, 2023
0db9419
Update and rename Easton redux.md to Easton_redux.md
jhimpele Jun 8, 2023
5d17a10
Update Easton_redux.md
jhimpele Jun 8, 2023
15234ee
Update and rename walking deceit.md to walking_deceit.md
jhimpele Jun 8, 2023
01dcdbb
Rename Tlingit-art to Tlingit_art.md
jhimpele Jun 8, 2023
f68afc6
Rename Tlingit_art.md to Tlingit_art
jhimpele Jun 8, 2023
422fc84
Update walking-purchase.md
jhimpele Jun 8, 2023
d35edde
Update bethel-mission.md
jhimpele Jun 8, 2023
ebb03cf
Update wisconsin-munsee.md
jhimpele Jun 8, 2023
13881af
Update removal-act.md
jhimpele Jun 8, 2023
abce02a
Update religious-freedom.md
jhimpele Jun 8, 2023
2097e70
Update bethel-mission.md
jhimpele Jun 8, 2023
a38b097
Rename 1866-delaware-treaty.md to 1866_delaware_treaty.md
jhimpele Jun 8, 2023
affcdc9
Update kansas.md
jhimpele Jun 8, 2023
eacb5ad
Update princeton-university.md
jhimpele Jun 9, 2023
a22bfb3
Update Easton_redux.md
jhimpele Jun 9, 2023
1de859d
Update complaints.md
jhimpele Jun 9, 2023
13b7ac8
Update brotherton-collapse.md
jhimpele Jun 9, 2023
8dde2ea
Update brotherton-pact.md
jhimpele Jun 9, 2023
b6b941f
Update brotherton-res.md
jhimpele Jun 9, 2023
afba1ba
Update easton-treaty-signed.md
jhimpele Jun 9, 2023
3075072
Update easton-treaty.md
jhimpele Jun 9, 2023
4911a8b
Update munsee-three-sisters-farm.md
jhimpele Jun 9, 2023
e4d833b
Update college-of-nj-opens.md
jhimpele Jun 9, 2023
8771cac
Update brotherton-pact.md
jhimpele Jun 9, 2023
286f6a8
Update brotherton-collapse.md
jhimpele Jun 9, 2023
09e1e15
Update ramapough-lenape.md
jhimpele Jun 9, 2023
f83f0b4
Update library-recognitions.md
jhimpele Jun 9, 2023
6e96bb0
Update library-collections.md
jhimpele Jun 9, 2023
f96fd88
Update Easton_redux.md
jhimpele Jun 9, 2023
628a613
Update 1866_delaware_treaty.md
jhimpele Jun 9, 2023
b0c1866
Update delaware-treaty.md
jhimpele Jun 9, 2023
2386f8d
Update language-alliance.md
jhimpele Jun 9, 2023
5b199b6
Update 1866_delaware_treaty.md
jhimpele Jun 9, 2023
adcdb3d
Update departure.md
jhimpele Jun 9, 2023
592fc32
Update cultural_survival.md
jhimpele Jun 9, 2023
ca0f3cc
Rename sheldon-jackson.md to cultural_survival.md
jhimpele Jun 9, 2023
c4f7254
Update cultural-property.md
jhimpele Jun 9, 2023
7d469d4
Update cultural-property.md
jhimpele Jun 9, 2023
c6f96a1
Update cultural-property.md
jhimpele Jun 9, 2023
acc684b
Update recognition-of-ritual-authority.md
jhimpele Jun 9, 2023
4920af6
Update cultural-property.md
jhimpele Jun 9, 2023
a338235
Rename cultural_survival.md to cultural-survival.md
jhimpele Jun 9, 2023
2d0aa69
Update cultural-survival.md
jhimpele Jun 9, 2023
64163fc
Update conference.md
jhimpele Jun 9, 2023
d82cc31
Update william-potter-ross.md
jhimpele Jun 9, 2023
1b9235a
Update william-potter-ross.md
jhimpele Jun 9, 2023
7487495
Update british-alliance.md
jhimpele Jun 9, 2023
7bec3a4
Update 1866_delaware_treaty.md
jhimpele Jun 9, 2023
f8b77ae
Update archives.md
jhimpele Jun 9, 2023
647350e
Update activism.md
jhimpele Jun 9, 2023
f680619
Update library-collections.md
jhimpele Jun 9, 2023
40011d3
Update independence.md
jhimpele Jun 9, 2023
42efa56
Update B_Calvin.md
jhimpele Jun 9, 2023
683ad81
Update william-potter-ross.md
jhimpele Jun 9, 2023
3691489
Update credits.md
jhimpele Jun 9, 2023
9c4ac55
Update credits.md
jhimpele Jun 9, 2023
4b55059
Update greenville-treaty.md
jhimpele Jun 9, 2023
84c9e32
Update 1866_delaware_treaty.md
jhimpele Jun 9, 2023
d275a3f
Update pres-edwards.md
jhimpele Jun 9, 2023
bc3e0a9
Update mannahatta.md
jhimpele Jun 9, 2023
07515ae
Update pontiac.md
jhimpele Jun 9, 2023
b426a4f
Update lenapewihittuck.md
jhimpele Jun 9, 2023
a864a04
Update lenapewihittuck.md
jhimpele Jun 9, 2023
0d2e3cc
Update lunaapahkiing.md
jhimpele Jun 9, 2023
c80e72e
Correct tag typo
rlskoeser Jun 9, 2023
9505826
Correct VizE lab logo and link
rlskoeser Jun 9, 2023
b7261d2
Adjust alignment and spacing for tag index page on desktop
rlskoeser Jun 9, 2023
34b4267
Update fallen-timbers.md
jhimpele Jun 10, 2023
03f4420
Update Trustee.md (#247)
jhimpele Jun 12, 2023
bbae575
Update assunpink.md (#244)
jhimpele Jun 12, 2023
5b4c627
Update fallen-timbers.md (#245)
jhimpele Jun 12, 2023
b7dc8d1
Rename trustee leaf to use lower case
rlskoeser Jun 12, 2023
88957eb
Set version to 1.0
rlskoeser Jun 12, 2023
bccbcc2
Merge branch 'main' into release/1.0
rlskoeser Jun 12, 2023
5e03c75
Set version as a string instead of a number, so trailing zeroes show
rlskoeser Jun 12, 2023
29ac1a6
Only include google analytics for hugo production builds
rlskoeser Jun 12, 2023
a69bb92
Clarify project role vs affiliation for researchers on credits page
rlskoeser Jun 12, 2023
9017494
Fix NAISIP poster caption/attribution logic
rlskoeser Jun 12, 2023
fad79db
Remove Percy visual review workflow and readme badge
rlskoeser Jun 12, 2023
18ce950
implement link icons (#248)
rlskoeser Jun 12, 2023
dcb5786
implement link icons (#248)
rlskoeser Jun 12, 2023
60a9817
Downgrade some lighthouse errors to warnings
rlskoeser Jun 12, 2023
be293c2
Update credits page
rlskoeser Jun 13, 2023
6cda2b7
Extend the trunk beyond the svg even further
rlskoeser Jun 13, 2023
c268f60
add as twitter summary card
gissoo Jun 13, 2023
232a5ee
add as card for linkedin, mastodon, and facebook
gissoo Jun 13, 2023
a178450
Correct typo
rlskoeser Jun 13, 2023
28df695
Add twitter card and opengraph metadata to page header
rlskoeser Jun 13, 2023
095a244
Add twitter card and opengraph metadata to page header
rlskoeser Jun 13, 2023
f8ecc85
Document functionality and work included in 1.0 release
rlskoeser Jun 13, 2023
9c9874a
Merge branch 'release/1.0' into main
rlskoeser Jun 13, 2023
ff66a7d
Merge branch 'release/1.0' into develop
rlskoeser Jun 13, 2023
9078fe1
Update develop version to 1.1.0
rlskoeser Jun 13, 2023
fd2d9f0
Set develop version to indicate dev status
rlskoeser Jun 14, 2023
ccffa9e
Revise logo order in footer; center footer logos on mobile
rlskoeser Jul 19, 2023
c4b6649
Add titles and affiliations for core team members on credits page
rlskoeser Jul 19, 2023
86be2f0
Update credits (#252)
rlskoeser Jul 19, 2023
f4056d1
Revise leaves based on feedback from Keely (#253)
rlskoeser Jul 29, 2023
65a1de1
Merge branch 'main' into develop
rlskoeser Jul 29, 2023
4e9fdb8
Content revisions and cleanup (#254)
jhimpele Aug 8, 2023
4519cd5
Tweak citation and embedded metadata
rlskoeser Aug 8, 2023
5a6cb98
Set version to 1.0.1 and briefly document changes
rlskoeser Aug 8, 2023
2c272e7
Update project version in hugo site config
rlskoeser Aug 8, 2023
fb58fbe
Merge branch 'release/1.0.1'
rlskoeser Aug 8, 2023
235b309
Fix list formatting in panel
rlskoeser Aug 8, 2023
9db1dd6
Tweak project history text
rlskoeser Aug 8, 2023
8dc1049
Correct formatting problem and tweak project history text
rlskoeser Aug 8, 2023
3ea0523
Merge branch 'main' into dh-code-review
rlskoeser Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 239 additions & 0 deletions assets/js/branches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
import { line, curveNatural, curveBumpY } from "d3-shape";
import { select, selectAll } from "d3-selection";
import { randomNumBetween } from "./leaves";
import { BaseSVG } from "./utils";

// combine into d3 object for convenience
const d3 = {
line,
curveNatural,
curveBumpY,
select,
selectAll,
};

function drawTreeSegment(points) {
const curve = d3.line().curve(d3.curveBumpY);
return curve(points.map((d) => [d.x, d.y])); // [start, end]);
}

// how to do this? needs context/scale
// trunk width should be a constant,
// top/bottom coords should be fixed
// - needed for both tree and roots

const trunkWidth = 150; // 110;
const trunkBaseWidth = trunkWidth * 0.9;

const trunk = {
width: trunkWidth,
topLeft: -trunkWidth / 2,
topRight: trunkWidth / 2,
bottomLeft: -trunkBaseWidth / 2,
bottomRight: trunkBaseWidth / 2,
};

function drawTrunk(container, [min_x, min_y, width, height], trunkTop) {
// draw lines for the trunk,
// to make it easier to read as a tree

const max_y = min_y + height;

// extend trunk off the bottom edge of the svg,
// so that trunk and roots stay connected when resizing
const trunkExtra = 600;

// add points for unevenness at the thirds of the trunk
let onethird = (trunkTop - trunk.bottomLeft) / 4;

// generate points for left side
const leftSidePoints = [
[trunk.topLeft, trunkTop],
[trunk.topLeft * 0.9, trunkTop + onethird],
[trunk.topLeft * 0.8, trunkTop + onethird * 2],
[trunk.bottomLeft * 0.9, trunkTop + onethird * 3],
[trunk.bottomLeft, max_y],
[trunk.bottomLeft, max_y + trunkExtra],
].map((d) => {
return { x: d[0], y: d[1] };
});

// draw the path for the left side
container
.append("path")
.attr("class", "trunk")
.attr("d", drawTreeSegment(leftSidePoints));

// generate points for right side

const rightSidePoints = [
[trunk.topRight, trunkTop],
[trunk.topRight * 0.9, trunkTop + onethird],
[trunk.topRight * 0.95, trunkTop + onethird * 2],
[trunk.bottomRight * 0.9, trunkTop + onethird * 3],
[trunk.bottomRight, max_y],
[trunk.bottomRight, max_y + trunkExtra], // extend off the edge of the svg, for resizing
].map((d) => {
return { x: d[0], y: d[1] };
});

// draw the path for the right side
container
.append("path")
.attr("class", "trunk")
.attr("d", drawTreeSegment(rightSidePoints));
}

function drawBranches(nodes, container, branches, trunkTop) {
// draw branches

let branchNodes = nodes.filter((d) => d.type == "branch");
// calculate starting coordinates for each branch
// tree width is defined as a constant;
// assuming center of svg is 0,0
// top of tree is passed in from timetree code
let leftBranchX = -trunkWidth / 2;
// second branch starts up 1/3 of the trunk width
let secondBranchY = trunkWidth * 0.3;
// third and fourth stair step down in thirds
let steps = (trunkTop - secondBranchY) * 0.3;

// calculate starting coordinates for each of the five branches
let branchStart = [
// left-most branch
{ x: trunk.topLeft, y: trunkTop },
// [leftBranchX, trunkTop], // left-most branch
// second branch starts over 6% of tree width
{ x: trunk.topLeft + trunkWidth * 0.06, y: trunkTop - secondBranchY },
// third is 48% of width
{
x: trunk.topLeft + trunkWidth * 0.48,
y: trunkTop - secondBranchY + steps,
},
// fourth is 70% of width
{
x: trunk.topLeft + trunkWidth * 0.7,
y: trunkTop - secondBranchY + steps + steps,
},
// right-most branch
{ x: trunk.topRight, y: trunkTop },
];

// insert branches before node group layer,
// so it will render as underneath the leaves
let branchPaths = container
.insert("g", ".nodes")
.attr("class", "branches")
.selectAll("path")
.data(Object.keys(branches)) // join to branch names passed in
.join("path")
// draw branch path for leaves, empty path for everything else
.attr("class", "branch")
.attr("d", (b, i) => {
// start at the calculated branch point for this branch,
// then use branch pseudo nodes as coordinates
let branchPoints = [
branchStart[i],
...branchNodes.filter((d) => d.branch == b),
];
return drawTreeSegment(branchPoints);
});
}

class Roots extends BaseSVG {
constructor() {
super();

// configure so point [0, 0] is the center top of the svg

// use same logic as for the timetree svg width
let width = this.getSVGWidth(); // width depends on if mobile or not
let height = 130;
let min_x = -width / 2;
let min_y = 0;

// TODO: use a graphic for mobile,
// since it is decorative and not functional ?

let center_x = min_x + width / 2;

const svg = d3
.select("body > footer")
.append("svg")
.lower()
.attr("id", "roots")
.attr("viewBox", [min_x, min_y, width, height]);

// for debugging: mark the center of the svg
// svg
// .append("circle")
// .attr("r", 5)
// .attr("fill", "red")
// .attr("cx", min_x + width / 2)
// // .attr("cx", width / 2)
// // .attr("cx", 0)
// .attr("cy", min_y + height / 2);

const navLinks = document.querySelectorAll("body > footer > nav > a");
let linkCount = navLinks.length;
// divide into equal sections based on the number of nav links
let sectionwidth = width / linkCount + 1;

let center_y = height / 2;

let currentURL = window.location.pathname;

// draw one root for each footer nav link
navLinks.forEach((a, i) => {
// determine if left or right, based half point of leaves
let left = i < linkCount / 2;

let startx = left ? trunk.bottomLeft : trunk.bottomRight;
let targetX = min_x + sectionwidth * i + sectionwidth / 2;

// create a branch off point for secondary root line
let secondaryRootStart = [
// start part way to the target x coord
((targetX - startx) / 3) * 2 + (left ? -45 : 45),
// and somewhere between a third and a half of the svg height
randomNumBetween(height / 3, height / 2),
];

let rootCoords = [
[center_x + startx, min_y],
[center_x + startx + (left ? -8 : 8), min_y + 7],
secondaryRootStart,
[targetX, center_y],
[targetX + (left ? -25 : 25), height],
].map((d) => {
return { x: d[0], y: d[1] };
});

let path = drawTreeSegment(rootCoords);
let current = a.getAttribute("aria-current") == "page";
// set root as current if nav link page is for the current page
svg
.append("path")
.attr("class", `root ${current ? "current" : ""}`)
.attr("d", path);

let secondaryRootCoords = [
rootCoords[2], // = secondary root start
{
x: secondaryRootStart[0] + (left ? -43 : 43),
y: secondaryRootStart[1] + 52,
},
{ x: secondaryRootStart[0] + (left ? -55 : 55), y: height },
];

svg
.append("path")
.attr("class", "root")
.attr("d", drawTreeSegment(secondaryRootCoords));
});

// NOTE: html coords != svg coords, so bounding rects doesn't help
}
}

export { drawTreeSegment, Roots, drawTrunk, drawBranches };
51 changes: 51 additions & 0 deletions assets/js/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* mixin for keypress management */

import { select, selectAll } from "d3-selection";
// combine into d3 object for convenience
const d3 = {
select,
selectAll,
};

// mixin extends syntax from
// https://blog.bitsrc.io/inheritance-abstract-classes-and-class-mixin-in-javascript-c636ac00f5a9

const TimeTreeKeysMixin = (Base) =>
class extends Base {
bindKeypressHandler() {
// make panel object available in event handler context
let panel = this.panel;

document.onkeydown = function (evt) {
// Get event object
evt = evt || window.event;

// Keypress switch logic
switch (evt.key) {
// Escape key closes the panel
case "Escape":
case "Esc":
panel.close();
break;

// Enter or space key activates focused element with button role
case "Enter":
case " ":
// if target element has role=button (i.e. leaves in the tree),
// trigger click behavior
if (evt.target.getAttribute("role", "button")) {
d3.select(evt.target).dispatch("click");
}
break;

// ... Add other cases here for more keyboard commands ...

// Otherwise
default:
return; // Do nothing
}
};
}
};

export { TimeTreeKeysMixin };
45 changes: 45 additions & 0 deletions assets/js/labels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// const labelLineHeight = 18;
// multiplier to use for calculating size based on characters
// const pixelsPerChar = 7;

class LeafLabel {
static lineHeight = 18;
// multiplier to use for calculating size based on characters
static pixelsPerChar = 7;

constructor(label = null) {
this.text = label;
// always need parts and want to calculate once, so getter doesn't make sense
this.parts = this.splitLabel();
}

splitLabel() {
// split a leaf label into words for wrapping
// for now, splitting on whitespace, but could adjust
if (this.text == null || this.text == undefined) {
return ["no title"];
}
return this.text.split(" ");
}

get height() {
// height is based on line height and number of words
return this.parts.length * LeafLabel.lineHeight;
}

get width() {
// width is based on the longest word
return (
Math.max(...this.parts.map((w) => w.length)) * LeafLabel.pixelsPerChar
);
}

get radius() {
// calculate radius based on text content, for avoiding collision in
// the d3-force simulation
// determine whichever is bigger is the diameter; halve for radius
return Math.max(this.width, this.height) / 2.0;
}
}

export { LeafLabel };
Loading