Create ColorSelectorNode.js
Browse files- src/ColorSelectorNode.js +34 -0
src/ColorSelectorNode.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { memo } from 'react';
|
| 2 |
+
import { Handle, Position } from 'reactflow';
|
| 3 |
+
|
| 4 |
+
export default memo(({ data, isConnectable }) => {
|
| 5 |
+
return (
|
| 6 |
+
<>
|
| 7 |
+
<Handle
|
| 8 |
+
type="target"
|
| 9 |
+
position={Position.Left}
|
| 10 |
+
style={{ background: '#555' }}
|
| 11 |
+
onConnect={(params) => console.log('handle onConnect', params)}
|
| 12 |
+
isConnectable={isConnectable}
|
| 13 |
+
/>
|
| 14 |
+
<div>
|
| 15 |
+
Custom Color Picker Node: <strong>{data.color}</strong>
|
| 16 |
+
</div>
|
| 17 |
+
<input className="nodrag" type="color" onChange={data.onChange} defaultValue={data.color} />
|
| 18 |
+
<Handle
|
| 19 |
+
type="source"
|
| 20 |
+
position={Position.Right}
|
| 21 |
+
id="a"
|
| 22 |
+
style={{ top: 10, background: '#555' }}
|
| 23 |
+
isConnectable={isConnectable}
|
| 24 |
+
/>
|
| 25 |
+
<Handle
|
| 26 |
+
type="source"
|
| 27 |
+
position={Position.Right}
|
| 28 |
+
id="b"
|
| 29 |
+
style={{ bottom: 10, top: 'auto', background: '#555' }}
|
| 30 |
+
isConnectable={isConnectable}
|
| 31 |
+
/>
|
| 32 |
+
</>
|
| 33 |
+
);
|
| 34 |
+
});
|