Spaces:
Running

File size: 2,206 Bytes
d7b9d43
 
2740e39
d7b9d43
 
 
2740e39
 
d7b9d43
 
 
 
 
 
 
 
 
 
2740e39
 
 
 
 
 
 
d7b9d43
2740e39
 
 
 
 
 
d7b9d43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React from 'react';
import { getBezierPath, BaseEdge, useInternalNode } from '@xyflow/react';
import { floatingPoints } from './floatingEdge';

export default function StickerEdge({
  id,
  source,
  target,
  sourceX,
  sourceY,
  targetX,
  targetY,
  sourcePosition,
  targetPosition,
  style = {},
  selected,
  interactionWidth,
}) {
  const sourceNode = useInternalNode(source);
  const targetNode = useInternalNode(target);
  // Threads float between the facing sides of the sticker and its card
  const p = sourceNode && targetNode
    ? floatingPoints(sourceNode, targetNode, {})
    : { sx: sourceX, sy: sourceY, tx: targetX, ty: targetY, sourcePos: sourcePosition, targetPos: targetPosition };

  const [edgePath] = getBezierPath({
    sourceX: p.sx,
    sourceY: p.sy,
    sourcePosition: p.sourcePos,
    targetX: p.tx,
    targetY: p.ty,
    targetPosition: p.targetPos,
    curvature: 0.6, // More curved for a "hanging thread" feel
  });

  return (
    <>
      {/* Interaction area for easier clicking */}
      <path
        id={id}
        style={{ fill: 'none', strokeWidth: 20, stroke: 'transparent' }}
        className="react-flow__edge-interaction"
        d={edgePath}
      />
      
      {/* Shadow path */}
      <BaseEdge
        path={edgePath}
        style={{
          ...style,
          strokeWidth: 3,
          stroke: 'rgba(0,0,0,0.1)',
          fill: 'none',
          transform: 'translate(1px, 2px)',
        }}
      />
      
      {/* Main Thread */}
      <BaseEdge
        path={edgePath}
        style={{
          ...style,
          strokeWidth: selected ? 3 : 2,
          stroke: selected ? '#f59e0b' : '#94a3b8', // Amber when selected, slate otherwise
          strokeDasharray: '5 3', // Slightly longer dashes
          fill: 'none',
          strokeLinecap: 'round',
          transition: 'stroke 0.2s, stroke-width 0.2s',
        }}
      />

      {/* Optional: Small highlight on the thread */}
      <BaseEdge
        path={edgePath}
        style={{
          ...style,
          strokeWidth: 0.5,
          stroke: 'rgba(255,255,255,0.4)',
          fill: 'none',
          strokeDasharray: '2 10',
        }}
      />
    </>
  );
}