custom-connection-line.tsx 767 B

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