Implemented connection UI

This commit is contained in:
Emir Karabeg
2025-01-14 14:33:11 -08:00
parent 9177e197c5
commit 55d07fdb68
2 changed files with 47 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ import ReactFlow, {
XYPosition,
useReactFlow,
ReactFlowProvider,
ConnectionLineType,
} from 'reactflow'
import 'reactflow/dist/style.css'
import { getBlock } from '../components/blocks/configs'
@@ -104,6 +105,18 @@ function WorkflowCanvas() {
return (
<div className="w-full h-[calc(100vh-56px)]">
<style>
{`
@keyframes dashdraw {
from {
stroke-dashoffset: 10;
}
to {
stroke-dashoffset: -10;
}
}
`}
</style>
<ReactFlow
nodes={nodes}
edges={edges}
@@ -114,8 +127,26 @@ function WorkflowCanvas() {
onDrop={onDrop}
onDragOver={(e) => e.preventDefault()}
fitView
maxZoom={1}
maxZoom={1.1}
panOnScroll
defaultEdgeOptions={{
type: 'smoothstep',
style: {
stroke: '#94a3b8',
strokeWidth: 2,
strokeDasharray: '5',
strokeDashoffset: '0',
animation: 'dashdraw 1s linear infinite',
},
}}
connectionLineStyle={{
stroke: '#94a3b8',
strokeWidth: 2,
strokeDasharray: '5',
strokeDashoffset: '0',
animation: 'dashdraw 1s linear infinite',
}}
connectionLineType={ConnectionLineType.SmoothStep}
>
<Background />
</ReactFlow>

View File

@@ -2,6 +2,7 @@ import { Card } from '@/components/ui/card'
import { BlockConfig, SubBlockConfig } from '../../types/block'
import { SubBlock } from './sub-block/sub-block'
import { Handle, Position } from 'reactflow'
import { cn } from '@/lib/utils'
interface WorkflowBlockProps {
id: string
@@ -45,7 +46,13 @@ export function WorkflowBlock({ id, type, config, name }: WorkflowBlockProps) {
<Handle
type="target"
position={Position.Top}
className="w-3 h-3 bg-white border-2 border-blue-500"
className={cn(
'!w-3 !h-3',
'!bg-white !rounded-full !border !border-gray-200',
'!opacity-0 group-hover:!opacity-100',
'!transition-opacity !duration-200 !cursor-crosshair',
'hover:!border-blue-500'
)}
/>
<div className="flex items-center gap-3 p-3 border-b">
@@ -78,7 +85,13 @@ export function WorkflowBlock({ id, type, config, name }: WorkflowBlockProps) {
<Handle
type="source"
position={Position.Bottom}
className="w-3 h-3 bg-white border-2 border-blue-500"
className={cn(
'!w-3 !h-3',
'!bg-white !rounded-full !border !border-gray-200',
'!opacity-0 group-hover:!opacity-100',
'!transition-opacity !duration-200 !cursor-crosshair',
'hover:!border-blue-500'
)}
/>
</Card>
)