Skip to content

Commit 5a1e97b

Browse files
authored
Merge pull request #16 from oslabs-beta/AL/tailwind-node
AL/tailwind node
2 parents a58cc6a + 56a47cc commit 5a1e97b

File tree

9 files changed

+4468
-2500
lines changed

9 files changed

+4468
-2500
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"eslint": "^8.54.0",
7373
"glob": "^10.3.10",
7474
"mocha": "^10.2.0",
75+
"postcss-loader": "^7.3.3",
76+
"postcss-preset-env": "^9.3.0",
77+
"tailwindcss": "^3.3.6",
7578
"typescript": "^5.2.2",
7679
"webpack-cli": "^5.1.4"
7780
},

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="border-1 border-gray-500">
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="border-1 border-gray-500 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: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
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

1720
parsedData.forEach((item) => {
1821
const node = {
1922
id: (++this.id).toString(),
2023
data: {
2124
label: (
22-
<div key={this.id}>
23-
<ul>
24-
<li>{item.fileName}</li>
25-
<li>Client Component: {item.isClientComponent.toString()}</li>
26-
</ul>
25+
<div className={`-mx-2.5 -my-2.5 py-2 px-9 shadow-lg rounded-md border-2 border-gray-500 ${(item.isClientComponent) ? 'bg-orange-300' : 'bg-blue-300'}`}>
26+
<div className="flex justify-center place-items-center" key={this.id}>
27+
<div className="text-sm font-medium">{item.fileName}</div>
28+
</div>
2729
</div>
2830
)
2931
},
30-
type: item.depth === 0 ? 'input' : '',
31-
position: { x: 0, y: 0 },
32+
// type: item.depth === 0 ? 'input' : '',
33+
// type: item.isClientComponent ? 'input' : 'output',
34+
type: 'default',
35+
position: { x: x += 40, y: y += 30 },
3236
style: {
33-
backgroundColor: "var(--vscode-dropdown-background)",
34-
borderRadius: "15px",
35-
width: '265px',
36-
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)',
3737
border: 'none',
38-
padding: '10px 10px 3px 10px'
39-
},
38+
borderRadius: "6px"
39+
}
4040
};
4141
this.initialNodes.push(node);
4242
if (item.children) {
43-
this.buildNodesArray(item.children);
43+
this.buildNodesArray(item.children, this.x += 40, this.y += 30);
4444
}
4545
});
46-
// console.log('initialNodes', this.initialNodes);
4746
};
4847

4948
buildEdgesArray(parsedData, parentID) {
@@ -65,7 +64,6 @@ class FlowBuilder {
6564
this.buildEdgesArray(item.children, nodeID);
6665
}
6766
});
68-
// console.log('initialEdges', this.initialEdges);
6967
}
7068

7169
build(settings) {
@@ -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);

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)