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