custom-connection-line.tsx 758 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { memo } from 'react'
  2. import type { ConnectionLineComponentProps } from 'reactflow'
  3. import {
  4. Position,
  5. getSimpleBezierPath,
  6. } from 'reactflow'
  7. const CustomConnectionLine = ({ fromX, fromY, toX, toY }: ConnectionLineComponentProps) => {
  8. const [
  9. edgePath,
  10. ] = getSimpleBezierPath({
  11. sourceX: fromX,
  12. sourceY: fromY,
  13. sourcePosition: Position.Right,
  14. targetX: toX,
  15. targetY: toY,
  16. targetPosition: Position.Left,
  17. })
  18. return (
  19. <g>
  20. <path
  21. fill="none"
  22. stroke='#D0D5DD'
  23. strokeWidth={2}
  24. d={edgePath}
  25. />
  26. <rect
  27. x={toX}
  28. y={toY - 4}
  29. width={2}
  30. height={8}
  31. fill='#2970FF'
  32. />
  33. </g>
  34. )
  35. }
  36. export default memo(CustomConnectionLine)