Skip to content

Commit f4bd354

Browse files
committed
function added to take into account the name size of each component in ComponentMap file
> > Co-authored-by: Nkmai <[email protected]> Co-authored-by: lind-tania <[email protected]> Co-authored-by: rtviner <[email protected]> Co-authored-by: caitlinchan23 <[email protected]>
1 parent fd4a8c6 commit f4bd354

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface TreeNode {
2929

3030
type HierarchyNode = HierarchyPointNode<TreeNode>;
3131

32-
const defaultMargin = { top: 30, left: 30, right: 30, bottom: 70 };
32+
const defaultMargin = { top: 30, left: 30, right: 55, bottom: 70 };
3333

3434
export type LinkTypesProps = {
3535
width: number;
@@ -125,9 +125,15 @@ export default function ComponentMap({
125125
))}
126126

127127
{tree.descendants().map((node, key) => {
128-
const width = 65;
128+
// const width = (node.data.name.length) + 70;
129+
const widthFunc = (name) => {
130+
let nodeLength = name.length;
131+
if (nodeLength < 5) return nodeLength + 40;
132+
if (nodeLength < 10) return nodeLength + 60;
133+
return nodeLength + 70;
134+
}
135+
const width = widthFunc(node.data.name);
129136
const height = 25;
130-
131137

132138
let top: number;
133139
let left: number;
@@ -194,7 +200,7 @@ export default function ComponentMap({
194200
{/* Display text inside of each component node */}
195201
<text
196202
dy='.33em'
197-
fontSize={8}
203+
fontSize={10}
198204
fontFamily='Roboto'
199205
textAnchor='middle'
200206
style={{ pointerEvents: 'none' }}

0 commit comments

Comments
 (0)