ruv commited on
Commit
bdb3a97
·
verified ·
1 Parent(s): 87dac44

Create TurboEdge.tsx

Browse files
Files changed (1) hide show
  1. src/TurboEdge.tsx +39 -0
src/TurboEdge.tsx ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { EdgeProps, getBezierPath } from 'reactflow';
3
+
4
+ export default function CustomEdge({
5
+ id,
6
+ sourceX,
7
+ sourceY,
8
+ targetX,
9
+ targetY,
10
+ sourcePosition,
11
+ targetPosition,
12
+ style = {},
13
+ markerEnd,
14
+ }: EdgeProps) {
15
+ const xEqual = sourceX === targetX;
16
+ const yEqual = sourceY === targetY;
17
+
18
+ const [edgePath] = getBezierPath({
19
+ // we need this little hack in order to display the gradient for a straight line
20
+ sourceX: xEqual ? sourceX + 0.0001 : sourceX,
21
+ sourceY: yEqual ? sourceY + 0.0001 : sourceY,
22
+ sourcePosition,
23
+ targetX,
24
+ targetY,
25
+ targetPosition,
26
+ });
27
+
28
+ return (
29
+ <>
30
+ <path
31
+ id={id}
32
+ style={style}
33
+ className="react-flow__edge-path"
34
+ d={edgePath}
35
+ markerEnd={markerEnd}
36
+ />
37
+ </>
38
+ );
39
+ }