-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSidebar.jsx
More file actions
156 lines (148 loc) · 5 KB
/
Sidebar.jsx
File metadata and controls
156 lines (148 loc) · 5 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import React, { useState } from 'react';
import { useDnD } from './DnDContext';
import { nodeCategories, getNodeDisplayName } from '../nodeConfig.js';
export default () => {
const [_, setType] = useDnD();
const [expandedCategories, setExpandedCategories] = useState({
'Sources': false,
'Processing': true,
'Math': true,
'Control': false,
'Fuel Cycle': false,
'Output': true
});
const onDragStart = (event, nodeType) => {
setType(nodeType);
event.dataTransfer.effectAllowed = 'move';
};
const toggleCategory = (categoryName) => {
setExpandedCategories(prev => ({
...prev,
[categoryName]: !prev[categoryName]
}));
};
// Get CSS class for node based on category
const getNodeClass = (categoryName) => {
const categoryClasses = {
'Sources': 'dndnode input',
'Output': 'dndnode output',
'Processing': 'dndnode processing',
'Math': 'dndnode math',
'Others': 'dndnode others',
'Filters': 'dndnode filters',
'Control': 'dndnode control',
'Fuel Cycle': 'dndnode fuel-cycle'
};
return categoryClasses[categoryName] || 'dndnode';
};
return (
<aside style={{
padding: '16px',
height: '100%',
overflowY: 'auto',
backgroundColor: '#1e1e2f',
borderRight: '1px solid #555',
boxSizing: 'border-box'
}}>
<div className="description" style={{
marginBottom: '16px',
fontSize: '14px',
color: '#cccccc',
textAlign: 'center'
}}>
Drag nodes to the canvas to add them to your graph
</div>
{Object.entries(nodeCategories).map(([categoryName, categoryData]) => (
<div key={categoryName} style={{ marginBottom: '16px' }}>
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
cursor: 'pointer',
padding: '8px 12px',
backgroundColor: '#2c2c54',
borderRadius: '4px',
marginBottom: '8px',
userSelect: 'none'
}}
onClick={() => toggleCategory(categoryName)}
>
<h4 style={{
margin: 0,
fontSize: '14px',
fontWeight: 'bold',
color: '#ffffff'
}}>
{categoryName}
</h4>
<span style={{
fontSize: '12px',
transform: expandedCategories[categoryName] ? 'rotate(90deg)' : 'rotate(0deg)',
transition: 'transform 0.2s ease',
color: '#cccccc'
}}>
▶
</span>
</div>
{expandedCategories[categoryName] && (
<div style={{ paddingLeft: '8px' }}>
<div className="sidebar-description">
{categoryData.description}
</div>
{categoryData.nodes.map(nodeType => (
<div
key={nodeType}
className={getNodeClass(categoryName)}
draggable
style={{
margin: '4px 0',
padding: '8px 12px',
borderRadius: '4px',
cursor: 'grab',
fontSize: '13px',
transition: 'all 0.2s ease',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between'
}}
onMouseEnter={(e) => {
const currentBg = window.getComputedStyle(e.target).backgroundColor;
const currentBorder = window.getComputedStyle(e.target).borderLeftColor;
e.target.style.backgroundColor = currentBg;
e.target.style.borderColor = '#78A083';
e.target.style.borderLeftColor = currentBorder;
e.target.style.transform = 'translateX(4px)';
e.target.style.color = '#ffffff';
e.target.style.boxShadow = '0 2px 8px rgba(0,0,0,0.5)';
}}
onMouseLeave={(e) => {
e.target.style.borderColor = '#555';
e.target.style.transform = 'translateX(0px)';
e.target.style.color = '#ffffff';
e.target.style.boxShadow = 'none';
}}
onDragStart={(e) => {
e.target.style.cursor = 'grabbing';
onDragStart(e, nodeType);
}}
onDragEnd={(e) => {
e.target.style.cursor = 'grab';
}}
>
<span>{getNodeDisplayName(nodeType)}</span>
<span style={{
fontSize: '12px',
color: '#888',
}}>
⋮⋮
</span>
</div>
))}
</div>
)}
</div>
))}
</aside>
);
};