mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
Set up scaffolding for connections
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
|
interface ConnectionPointProps {
|
||||||
|
position: 'top' | 'bottom'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ConnectionPoint({ position }: ConnectionPointProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'absolute left-1/2 -translate-x-1/2 w-3 h-3',
|
||||||
|
'bg-white rounded-full border opacity-0 group-hover:opacity-100',
|
||||||
|
'transition-opacity duration-200 cursor-crosshair hover:border-blue-500',
|
||||||
|
'hover:scale-110 hover:shadow-sm',
|
||||||
|
position === 'top'
|
||||||
|
? '-translate-y-1/2 top-0'
|
||||||
|
: 'translate-y-1/2 bottom-0'
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Card } from '@/components/ui/card'
|
import { Card } from '@/components/ui/card'
|
||||||
import { BlockConfig, SubBlockConfig } from '../../types/block'
|
import { BlockConfig, SubBlockConfig } from '../../types/block'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { SubBlock } from './sub-block/sub-block'
|
import { SubBlock } from './components/sub-block/sub-block'
|
||||||
import { useCallback, useState, MouseEvent, useEffect } from 'react'
|
import { useCallback, useState, MouseEvent, useEffect } from 'react'
|
||||||
|
import { ConnectionPoint } from './components/connection/connection-point'
|
||||||
|
|
||||||
export interface WorkflowBlockProps {
|
export interface WorkflowBlockProps {
|
||||||
id: string
|
id: string
|
||||||
@@ -109,7 +110,7 @@ export function WorkflowBlock({
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
'absolute w-[320px] shadow-md cursor-move select-none',
|
'absolute w-[320px] shadow-md cursor-move select-none group',
|
||||||
'transform -translate-x-1/2 -translate-y-1/2',
|
'transform -translate-x-1/2 -translate-y-1/2',
|
||||||
isDragging && 'pointer-events-none'
|
isDragging && 'pointer-events-none'
|
||||||
)}
|
)}
|
||||||
@@ -119,6 +120,8 @@ export function WorkflowBlock({
|
|||||||
}}
|
}}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
>
|
>
|
||||||
|
<ConnectionPoint position="top" />
|
||||||
|
|
||||||
<div className="flex items-center gap-3 p-3 border-b">
|
<div className="flex items-center gap-3 p-3 border-b">
|
||||||
<div
|
<div
|
||||||
className="flex items-center justify-center w-7 h-7 rounded"
|
className="flex items-center justify-center w-7 h-7 rounded"
|
||||||
@@ -146,6 +149,8 @@ export function WorkflowBlock({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ConnectionPoint position="bottom" />
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user