Skip to content

Commit

Permalink
fix: Add padding to kind nodes
Browse files Browse the repository at this point in the history
This avoids overlaps between siblings.

Signed-off-by: George Thomas <[email protected]>
  • Loading branch information
georgefst committed Aug 29, 2023
1 parent 6f717bb commit ca7b083
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/TreeReactFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ const makePrimerNode = async (
...common,
// Square, with same height as other nodes.
width: common.height,
...(flavorSort(flavor) == "kind"
? {
padding: {
// Since these nodes are rotated, their width,
// as reported to the layout engine, is off by a factor of √2.
// We don't pad vertically since allowing some overlap in the y-axis actually looks better,
// due to the rotation and the fact that all non-leaf kind nodes have precisely two children.
left: (common.height * Math.sqrt(2) - common.height) / 2,
right: (common.height * Math.sqrt(2) - common.height) / 2,
},
}
: {}),
},
zIndex,
},
Expand Down

0 comments on commit ca7b083

Please sign in to comment.