feat(handles): validate connection
This commit is contained in:
@@ -19,6 +19,12 @@
|
||||
left: 10px;
|
||||
z-index: 4;
|
||||
}
|
||||
.react-flow__handle.connecting {
|
||||
background: orange;
|
||||
}
|
||||
.react-flow__handle.valid {
|
||||
background: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -9,6 +9,11 @@ export default({ data, styles }) => (
|
||||
<Handle type="target" position="left" style={{ background: '#999' }} />
|
||||
<div>{data.input}</div>
|
||||
<input onChange={(e) => data.onChange(e.target.value, data)} />
|
||||
<Handle type="source" position="right" style={{ background: '#999' }} />
|
||||
<Handle
|
||||
type="source"
|
||||
position="right"
|
||||
style={{ background: '#999' }}
|
||||
isValidConnection={connection => +connection.target % 2 === 0}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -26,7 +26,11 @@ export default ({ data, styles }) => {
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
</select>
|
||||
<Handle type="source" position="bottom" style={{ left: 10, background: '#999' }} />
|
||||
<Handle
|
||||
type="source"
|
||||
position="bottom"
|
||||
style={{ left: 10, background: '#999' }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user