Add more node type
This commit is contained in:
parent
a599e19ccc
commit
552f351949
26
frontend/src/components/ColorNode.jsx
Normal file
26
frontend/src/components/ColorNode.jsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { Handle, Position } from 'reactflow';
|
||||||
|
|
||||||
|
function ColorNode({ data }) {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
background: 'white',
|
||||||
|
border: '2px solid #ff0071',
|
||||||
|
borderRadius: 8,
|
||||||
|
padding: 10,
|
||||||
|
width: 120,
|
||||||
|
textAlign: 'center'
|
||||||
|
}}>
|
||||||
|
<Handle type="target" position={Position.Left} />
|
||||||
|
<div style={{ fontSize: 12, marginBottom: 6 }}>🎨 Shape Color</div>
|
||||||
|
<input
|
||||||
|
type="color"
|
||||||
|
value={data.color || '#ff0071'}
|
||||||
|
onChange={(e) => data.onChange?.(e.target.value)}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
/>
|
||||||
|
<Handle type="source" position={Position.Right} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ColorNode;
|
||||||
@ -17,10 +17,13 @@ import CustomNode from './CustomNode';
|
|||||||
import IconSelector from './IconSelector';
|
import IconSelector from './IconSelector';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import RouterNode from './RouterNode';
|
import RouterNode from './RouterNode';
|
||||||
|
import ColorNode from './ColorNode';
|
||||||
|
|
||||||
|
|
||||||
const nodeTypes = {
|
const nodeTypes = {
|
||||||
custom: CustomNode,
|
custom: CustomNode,
|
||||||
router: RouterNode,
|
router: RouterNode,
|
||||||
|
color: ColorNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
function Diagram() {
|
function Diagram() {
|
||||||
@ -296,6 +299,7 @@ function Diagram() {
|
|||||||
>
|
>
|
||||||
<option value="custom">🧱 Custom</option>
|
<option value="custom">🧱 Custom</option>
|
||||||
<option value="router">📡 Router</option>
|
<option value="router">📡 Router</option>
|
||||||
|
<option value="color">🎨 Color Node</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
{newType === 'custom' && (
|
{newType === 'custom' && (
|
||||||
|
|||||||
14
frontend/src/components/RouterNode.jsx
Normal file
14
frontend/src/components/RouterNode.jsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// components/RouterNode.js
|
||||||
|
import { Handle, Position } from 'reactflow';
|
||||||
|
|
||||||
|
function RouterNode({ data }) {
|
||||||
|
return (
|
||||||
|
<div style={{ border: '2px dashed #ff9800', borderRadius: 6, padding: 10, width: 100, textAlign: 'center' }}>
|
||||||
|
<Handle type="target" position={Position.Top} />
|
||||||
|
<div>📡 {data.label}</div>
|
||||||
|
<Handle type="source" position={Position.Bottom} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RouterNode;
|
||||||
Loading…
x
Reference in New Issue
Block a user