mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Added select edge color change
This commit is contained in:
+33
-8
@@ -16,6 +16,9 @@ import ReactFlow, {
|
||||
useReactFlow,
|
||||
ReactFlowProvider,
|
||||
ConnectionLineType,
|
||||
BaseEdge,
|
||||
EdgeProps,
|
||||
getSmoothStepPath,
|
||||
} from 'reactflow'
|
||||
import 'reactflow/dist/style.css'
|
||||
import { getBlock } from '../components/blocks/configs'
|
||||
@@ -48,6 +51,34 @@ const nodeTypes: NodeTypes = {
|
||||
workflowBlock: WorkflowNode,
|
||||
}
|
||||
|
||||
// Add this custom edge component
|
||||
const CustomEdge = (props: EdgeProps) => {
|
||||
const [edgePath] = getSmoothStepPath({
|
||||
sourceX: props.sourceX,
|
||||
sourceY: props.sourceY,
|
||||
targetX: props.targetX,
|
||||
targetY: props.targetY,
|
||||
})
|
||||
|
||||
return (
|
||||
<BaseEdge
|
||||
{...props}
|
||||
path={edgePath}
|
||||
style={{
|
||||
stroke: props.selected ? '#475569' : '#94a3b8',
|
||||
strokeWidth: 2,
|
||||
strokeDasharray: '5',
|
||||
strokeDashoffset: '0',
|
||||
animation: 'dashdraw 1s linear infinite',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const edgeTypes: EdgeTypes = {
|
||||
custom: CustomEdge,
|
||||
}
|
||||
|
||||
// Main Canvas Component
|
||||
function WorkflowCanvas() {
|
||||
// State
|
||||
@@ -130,15 +161,9 @@ function WorkflowCanvas() {
|
||||
maxZoom={1.1}
|
||||
panOnScroll
|
||||
defaultEdgeOptions={{
|
||||
type: 'smoothstep',
|
||||
style: {
|
||||
stroke: '#94a3b8',
|
||||
strokeWidth: 2,
|
||||
strokeDasharray: '5',
|
||||
strokeDashoffset: '0',
|
||||
animation: 'dashdraw 1s linear infinite',
|
||||
},
|
||||
type: 'custom',
|
||||
}}
|
||||
edgeTypes={edgeTypes}
|
||||
connectionLineStyle={{
|
||||
stroke: '#94a3b8',
|
||||
strokeWidth: 2,
|
||||
|
||||
Reference in New Issue
Block a user