Skip to content

Commit ea62eb7

Browse files
committed
changes to history component updating link paths to visually show the path to current node in the tree more clearly
1 parent 4a0c107 commit ea62eb7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/app/components/StateRoute/History.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function History(props: Record<string, unknown>): JSX.Element {
156156
const d3root = tree(root); // create a d3. tree from our root
157157
const currNode = labelCurrentNode(d3root); // iterate through our nodes and apply a color property
158158

159-
const g = svg //serves as a container for the nodes and links withi nthe D3 Visualization
159+
const g = svg //serves as a container for the nodes and links within the D3 Visualization of the tree
160160
.append('g') // create an element 'g' on svg
161161
.attr(
162162
'transform',
@@ -175,7 +175,14 @@ function History(props: Record<string, unknown>): JSX.Element {
175175
`M${d.x},${d.y}C${d.x},${(d.y + d.parent.y) / 2} ${d.parent.x},${
176176
(d.y + d.parent.y) / 2
177177
} ${d.parent.x},${d.parent.y}`,
178-
);
178+
)
179+
.attr('class', (d) => {
180+
// Adding a class based on the current node's data
181+
if (d.data.index === currLocation.index) {
182+
return 'link current-link'; // Apply both 'link' and 'current-link' classes
183+
}
184+
return 'link'; // Apply only the 'link' class
185+
});
179186

180187
const node = g
181188
.selectAll('.node')

src/app/styles/layout/_stateContainer.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,13 @@
263263
.tooltipData-JSONTree::-webkit-scrollbar-track {
264264
background: #51565e;
265265
}
266+
267+
.link {
268+
stroke: #ccc;
269+
stroke-width: 1.5;
270+
}
271+
272+
.current-link {
273+
stroke: red;
274+
stroke-width: 2.5; /* Adjust the width as needed */
275+
}

0 commit comments

Comments
 (0)