Added a nodes and edges file to ensure customizability, connected it to pipelineblock

pull/33/head
Khwaja 3 months ago
parent 7df33d20cf
commit 5a3c3564b5

@ -0,0 +1,22 @@
import React from 'react';
import { Position, NodeProps, Handle } from '@xyflow/react';
export interface CustomNodeData {
label: string;
type: 'plant' | 'product';
}
export default function CustomNode({ data }: NodeProps<any>) {
const nodeStyle =
data.type === 'plant'
? { background: '#b0e0e6', padding: 10, borderRadius: 5 }
: { background: '#ffd700', padding: 10, borderRadius: 5 };
return (
<div style={nodeStyle}>
<Handle type="target" position={Position.Left} style={{ background: '#555' }} />
<div>{data.label}</div>
<Handle type="source" position={Position.Right} style={{ background: '#555' }} />
</div>
);
};

@ -6,6 +6,7 @@ import Section from '../Common/Section';
import Card from '../Common/Card'; import Card from '../Common/Card';
import { useEffect } from "react"; import { useEffect } from "react";
import { Connection } from '@xyflow/react'; import { Connection } from '@xyflow/react';
import CustomNode, { CustomNodeData }from "./NodesAndEdges";
@ -90,7 +91,7 @@ const onNodeDragStop =(_:any, node: Node) => {
}); });
} }
for (const outputProduct of plant.inputs){ /**for (const outputProduct of plant.inputs){
edges.push({ edges.push({
id: `${plantName}-${outputProduct}`, id: `${plantName}-${outputProduct}`,
source: plantName, source: plantName,
@ -100,6 +101,7 @@ const onNodeDragStop =(_:any, node: Node) => {
}); });
} }
*/
} }
} }
@ -128,6 +130,7 @@ return (
minZoom={0.5} minZoom={0.5}
snapToGrid={true} snapToGrid={true}
preventScrolling={false} preventScrolling={false}
nodeTypes={{default: CustomNode}}
> >
<Background /> <Background />
<Controls showInteractive={false} /> <Controls showInteractive={false} />

Loading…
Cancel
Save