Skip to content

Commit 3e93c71

Browse files
authored
Merge pull request #18 from oslabs-beta/dev
Dev
2 parents 1fbf1ab + f6f2a5a commit 3e93c71

File tree

9 files changed

+4471
-2501
lines changed

9 files changed

+4471
-2501
lines changed

package-lock.json

Lines changed: 4391 additions & 2457 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"lint": "eslint .",
6363
"pretest": "npm run lint",
6464
"test": "node ./test/runTest.js",
65+
"dev": "webpack --watch",
6566
"webpack": "webpack"
6667
},
6768
"devDependencies": {
@@ -72,6 +73,9 @@
7273
"eslint": "^8.54.0",
7374
"glob": "^10.3.10",
7475
"mocha": "^10.2.0",
76+
"postcss-loader": "^7.3.3",
77+
"postcss-preset-env": "^9.3.0",
78+
"tailwindcss": "^3.3.6",
7579
"typescript": "^5.2.2",
7680
"webpack-cli": "^5.1.4"
7781
},

postcss.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const tailwindcss = require('tailwindcss');
2+
module.exports = {
3+
plugins: [
4+
'postcss-preset-env',
5+
tailwindcss
6+
],
7+
};

src/webview/Flow.jsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import React, { useCallback, useEffect, useState } from "react";
1+
import React, { useCallback, useEffect } from "react";
22
import ReactFlow, {
33
addEdge,
44
MiniMap,
5+
Panel,
56
Controls,
67
Background,
78
useNodesState,
89
useEdgesState
910
} from "reactflow";
10-
import "reactflow/dist/style.css"
11+
12+
import "reactflow/dist/style.css";
1113

1214
import FlowBuilder from './flowBuilder.js';
1315

@@ -33,9 +35,9 @@ const OverviewFlow = () => {
3335
case 'parsed-data': {
3436
const results = new FlowBuilder(msg.value);
3537
results.build(msg.settings)
36-
console.log('results: ', results);
37-
console.log('results.initialNodes: ', results.initialNodes);
38-
console.log('results.initialEdges: ', results.initialEdges);
38+
// console.log('results: ', results);
39+
// console.log('results.initialNodes: ', results.initialNodes);
40+
// console.log('results.initialEdges: ', results.initialEdges);
3941
setNodes(results.initialNodes);
4042
setEdges(results.initialEdges);
4143
break;
@@ -58,22 +60,31 @@ const OverviewFlow = () => {
5860
<MiniMap
5961
nodeStrokeColor={(n) => {
6062
if (n.style?.background) return n.style.background;
61-
if (n.type === "input") return "#0041d0";
62-
if (n.type === "output") return "#ff0072";
63+
if (n.data.label.props.className.includes('orange')) return "#fdba74";
64+
if (n.data.label.props.className.includes('blue')) return "#93C5FD";
6365
if (n.type === "default") return "#1a192b";
6466

6567
return "#eee";
6668
}}
6769
nodeColor={(n) => {
6870
if (n.style?.background) return n.style.background;
69-
7071
return "#fff";
7172
}}
7273
nodeBorderRadius={2}
7374
/>
75+
<Panel position="top-left">
76+
<div className="text-black">
77+
<div className="flex justify-end place-items-end shadow-lg bg-slate-50 w-20 h-15">
78+
<p className="pl-2 pr-2 py-2">Client: <span className="bg-orange-300 text-transparent rounded-full">00</span></p>
79+
</div>
80+
<div className="flex justify-end place-items-end shadow-lg bg-slate-50 w-20 h-15">
81+
<p className="pl-2 pr-2 pb-2">Server: <span className="bg-blue-300 text-transparent rounded-full">00</span></p>
82+
</div>
83+
</div>
84+
</Panel >
7485
<Controls />
7586
<Background color="#aaa" gap={16} />
76-
</ReactFlow>
87+
</ReactFlow >
7788
);
7889
};
7990

src/webview/flowBuilder.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
import React from 'react';
22
// will create a build func and then call the helper funcs to return an object
33
// make a new instance of this class in flow, call the build method, and pass this as state
4+
45
class FlowBuilder {
56
constructor(data) {
67
this.parsedData = [data];
78
this.id = 0;
9+
this.x = 0;
10+
this.y = 0;
811
this.initialNodes = [];
912
this.viewData;
1013
this.edgeId = 0;
1114
this.initialEdges = [];
1215
}
1316

14-
buildNodesArray(parsedData) {
17+
buildNodesArray(parsedData, x = this.x, y = this.y) {
1518
if (!parsedData) return;
1619

20+
1721
parsedData.forEach((item) => {
1822
const node = {
1923
id: (++this.id).toString(),
2024
data: {
2125
label: (
22-
<div key={this.id}>
23-
<ul>
24-
<li>{item.fileName}</li>
25-
<li>Client Component: {item.isClientComponent.toString()}</li>
26-
</ul>
27-
</div>
26+
<div className="text-sm font-medium text-ellipsis overflow-hidden ..." key={this.id}>{item.fileName}</div>
2827
)
2928
},
30-
type: item.depth === 0 ? 'input' : '',
31-
position: { x: 0, y: 0 },
29+
// type: item.depth === 0 ? 'input' : '',
30+
type: 'default',
31+
position: { x: x += 40, y: y += 30 },
3232
style: {
33-
backgroundColor: "var(--vscode-dropdown-background)",
34-
borderRadius: "15px",
35-
width: '265px',
36-
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)',
37-
border: 'none',
38-
padding: '10px 10px 3px 10px'
33+
borderRadius: '6px',
34+
borderWidth: '2px',
35+
borderColor: '#6b7280',
36+
display: 'flex',
37+
justifyContent: 'center',
38+
placeItems: 'center',
39+
backgroundColor: `${(item.isClientComponent) ? '#fdba74' : '#93C5FD'}`,
3940
},
4041
};
4142
this.initialNodes.push(node);
4243
if (item.children) {
43-
this.buildNodesArray(item.children);
44+
this.buildNodesArray(item.children, this.x += 40, this.y += 30);
4445
}
4546
});
46-
// console.log('initialNodes', this.initialNodes);
4747
};
4848

4949
buildEdgesArray(parsedData, parentID) {
@@ -65,7 +65,6 @@ class FlowBuilder {
6565
this.buildEdgesArray(item.children, nodeID);
6666
}
6767
});
68-
// console.log('initialEdges', this.initialEdges);
6968
}
7069

7170
build(settings) {
@@ -98,7 +97,7 @@ class FlowBuilder {
9897
});
9998
}
10099
traverse(treeParsed);
101-
// Update the vewData state
100+
// Update the viewData state
102101
this.viewData = ([treeParsed]);
103102
console.log('viewData:', this.viewData);
104103
this.buildNodesArray(this.viewData);

src/webview/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import { createRoot } from "react-dom/client";
3+
import './style.css';
34

45
import App from "./App.jsx";
56

src/webview/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
15
html,
26
body,
37
#root,

tailwind.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
content: ['./build/bundle.js'],
3+
theme: {
4+
extend: {},
5+
},
6+
variants: {
7+
extend: {},
8+
},
9+
plugins: [],
10+
important: true,
11+
}

webpack.config.cjs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const path = require('path')
22

3-
43
module.exports = {
5-
entry: './src/webview/index.jsx',
4+
entry: './src/webview/index.jsx',
65
output: {
76
filename: 'bundle.js',
87
path: path.resolve(__dirname, './build'),
@@ -12,20 +11,20 @@ entry: './src/webview/index.jsx',
1211
},
1312
module: {
1413
rules: [
15-
{
16-
test: /\.jsx?/,
17-
exclude: /node_modules/,
18-
use: {
19-
loader: "babel-loader",
20-
options: {
21-
presets: ['@babel/preset-env', '@babel/preset-react']
22-
}
23-
}
24-
},
25-
{
26-
test: /\.(scss|css)$/,
27-
use: ["style-loader", "css-loader"],
28-
},
14+
{
15+
test: /\.jsx?/,
16+
exclude: /node_modules/,
17+
use: {
18+
loader: "babel-loader",
19+
options: {
20+
presets: ['@babel/preset-env', '@babel/preset-react']
21+
}
22+
}
23+
},
24+
{
25+
test: /\.(css|scss)$/,
26+
use: ["style-loader", "css-loader", "postcss-loader"],
27+
},
2928
]
3029
},
3130
mode: "development"

0 commit comments

Comments
 (0)