chore(examples): cleanup
This commit is contained in:
@@ -8,6 +8,7 @@ import ReactFlow, {
|
||||
Node,
|
||||
Edge,
|
||||
useReactFlow,
|
||||
Panel,
|
||||
} from 'reactflow';
|
||||
|
||||
const onNodeDrag = (_: MouseEvent, node: Node) => console.log('drag', node);
|
||||
@@ -98,20 +99,12 @@ const BasicFlow = () => {
|
||||
<MiniMap />
|
||||
<Controls />
|
||||
|
||||
<div style={{ position: 'absolute', right: 10, top: 10, zIndex: 4 }}>
|
||||
<button onClick={resetTransform} style={{ marginRight: 5 }}>
|
||||
reset transform
|
||||
</button>
|
||||
<button onClick={updatePos} style={{ marginRight: 5 }}>
|
||||
change pos
|
||||
</button>
|
||||
<button onClick={toggleClassnames} style={{ marginRight: 5 }}>
|
||||
toggle classnames
|
||||
</button>
|
||||
<button onClick={logToObject} style={{ marginRight: 5 }}>
|
||||
toObject
|
||||
</button>
|
||||
</div>
|
||||
<Panel position="top-right">
|
||||
<button onClick={resetTransform}>reset transform</button>
|
||||
<button onClick={updatePos}>change pos</button>
|
||||
<button onClick={toggleClassnames}>toggle classnames</button>
|
||||
<button onClick={logToObject}>toObject</button>
|
||||
</Panel>
|
||||
</ReactFlow>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Handle, NodeProps, Position, ReactFlowState, useStore } from 'reactflow
|
||||
|
||||
const connectionNodeIdSelector = (state: ReactFlowState) => state.connectionNodeId;
|
||||
|
||||
export default function CustomNode({ id }: NodeProps) {
|
||||
export default function CustomNode({ id, isConnectable }: NodeProps) {
|
||||
const connectionNodeId = useStore(connectionNodeIdSelector);
|
||||
const isTarget = connectionNodeId && connectionNodeId !== id;
|
||||
|
||||
@@ -18,8 +18,20 @@ export default function CustomNode({ id }: NodeProps) {
|
||||
backgroundColor: isTarget ? '#ffcce3' : '#ccd9f6',
|
||||
}}
|
||||
>
|
||||
<Handle className="targetHandle" style={{ zIndex: 2 }} position={Position.Right} type="source" />
|
||||
<Handle className="targetHandle" style={targetHandleStyle} position={Position.Left} type="target" />
|
||||
<Handle
|
||||
className="targetHandle"
|
||||
style={{ zIndex: 2 }}
|
||||
position={Position.Right}
|
||||
type="source"
|
||||
isConnectable={isConnectable}
|
||||
/>
|
||||
<Handle
|
||||
className="targetHandle"
|
||||
style={targetHandleStyle}
|
||||
position={Position.Left}
|
||||
type="target"
|
||||
isConnectable={isConnectable}
|
||||
/>
|
||||
{label}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user