Skip to content

Commit 56a47cc

Browse files
committed
Fixed temporary layout for each node
1 parent 343024c commit 56a47cc

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/webview/flowBuilder.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import React from 'react';
2-
// import CustomNode from '../styles/CustomNode';
32
// will create a build func and then call the helper funcs to return an object
43
// make a new instance of this class in flow, call the build method, and pass this as state
5-
// const nodeTypes = {
6-
// custom: CustomNode,
7-
// };
84

95
class FlowBuilder {
106
constructor(data) {
117
this.parsedData = [data];
128
this.id = 0;
9+
this.x = 0;
10+
this.y = 0;
1311
this.initialNodes = [];
1412
this.viewData;
1513
this.edgeId = 0;
1614
this.initialEdges = [];
1715
}
1816

19-
buildNodesArray(parsedData) {
17+
buildNodesArray(parsedData, x = this.x, y = this.y) {
2018
if (!parsedData) return;
2119

2220
parsedData.forEach((item) => {
@@ -34,15 +32,15 @@ class FlowBuilder {
3432
// type: item.depth === 0 ? 'input' : '',
3533
// type: item.isClientComponent ? 'input' : 'output',
3634
type: 'default',
37-
position: { x: 0, y: 0 },
35+
position: { x: x += 40, y: y += 30 },
3836
style: {
3937
border: 'none',
4038
borderRadius: "6px"
4139
}
4240
};
4341
this.initialNodes.push(node);
4442
if (item.children) {
45-
this.buildNodesArray(item.children);
43+
this.buildNodesArray(item.children, this.x += 40, this.y += 30);
4644
}
4745
});
4846
};
@@ -98,7 +96,7 @@ class FlowBuilder {
9896
});
9997
}
10098
traverse(treeParsed);
101-
// Update the vewData state
99+
// Update the viewData state
102100
this.viewData = ([treeParsed]);
103101
console.log('viewData:', this.viewData);
104102
this.buildNodesArray(this.viewData);

0 commit comments

Comments
 (0)