Spaces:
Configuration error

File size: 2,310 Bytes
420bd16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
87
88
89
90
91
92
93
94
95
96
97
98
99
import React from 'react';
import { Handle, Position } from 'reactflow';

export const SHAPES = {
  RECTANGLE: 'rectangle',
  CIRCLE: 'circle',
  DIAMOND: 'diamond',
  HEXAGON: 'hexagon',
  PARALLELOGRAM: 'parallelogram',
};

export const getNodeStyle = (nodeType, shape, isRoot, isExpanded) => {
  const baseStyle = {
    padding: '10px 20px',
    borderRadius: '4px',
    fontSize: '14px',
    transition: 'all 0.2s ease',
    border: '1px solid #3498db',
  };

  // Shape-specific styles
  switch (shape) {
    case SHAPES.CIRCLE:
      return {
        ...baseStyle,
        borderRadius: '50%',
        width: '120px',
        height: '120px',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        padding: '10px',
      };
    case SHAPES.DIAMOND:
      return {
        ...baseStyle,
        transform: 'rotate(45deg)',
        width: '100px',
        height: '100px',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        '& > *': {
          transform: 'rotate(-45deg)',
        },
      };
    case SHAPES.HEXAGON:
      return {
        ...baseStyle,
        clipPath: 'polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)',
        width: '120px',
        height: '100px',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
      };
    case SHAPES.PARALLELOGRAM:
      return {
        ...baseStyle,
        transform: 'skew(-20deg)',
        '& > *': {
          transform: 'skew(20deg)',
        },
      };
    default:
      return baseStyle;
  }
};

export const CustomNode = ({ data, isConnectable }) => {
  return (
    <>
      <Handle
        type="target"
        position={Position.Top}
        isConnectable={isConnectable}
      />
      <Handle
        type="target"
        position={Position.Left}
        isConnectable={isConnectable}
      />
      <div className="node-content">
        {data.label}
        {data.icon && <i className={data.icon} style={{ marginLeft: '8px' }} />}
      </div>
      <Handle
        type="source"
        position={Position.Right}
        isConnectable={isConnectable}
      />
      <Handle
        type="source"
        position={Position.Bottom}
        isConnectable={isConnectable}
      />
    </>
  );
};