00Boobs00 commited on
Commit
51ffd60
·
verified ·
1 Parent(s): 591fafa

Upload components/Toolbar.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/Toolbar.js +74 -44
components/Toolbar.js CHANGED
@@ -1,90 +1,120 @@
1
  import { useState } from 'react'
2
- import { Layers, Database, Activity, Filter, Settings, ChevronDown } from 'lucide-react'
 
 
 
3
 
4
  const toolbarItems = [
5
  {
6
  category: 'Input',
7
  icon: Database,
8
  color: 'text-blue-600',
9
- items: ['Input Layer', 'Embedding', 'Data Augmentation']
 
 
 
 
 
10
  },
11
  {
12
  category: 'Core',
13
  icon: Layers,
14
  color: 'text-purple-600',
15
- items: ['Dense', 'Convolution', 'Recurrent', 'Transformer']
 
 
 
 
 
 
16
  },
17
  {
18
  category: 'Activation',
19
  icon: Activity,
20
  color: 'text-green-600',
21
- items: ['ReLU', 'Sigmoid', 'Tanh', 'Softmax']
 
 
 
 
 
 
22
  },
23
  {
24
  category: 'Regularization',
25
  icon: Filter,
26
  color: 'text-orange-600',
27
- items: ['Dropout', 'Batch Norm', 'Layer Norm']
 
 
 
 
 
28
  },
29
  {
30
  category: 'Output',
31
  icon: Settings,
32
  color: 'text-red-600',
33
- items: ['Output Layer', 'Loss Function', 'Metric']
 
 
 
 
 
34
  }
35
  ]
36
 
37
- export default function Toolbar() {
38
- const [expandedCategory, setExpandedCategory] = useState(null)
39
 
40
  const handleDragStart = (e, itemType) => {
41
  e.dataTransfer.setData('node-type', itemType)
 
42
  }
43
 
44
  return (
45
- <div className="w-64 bg-white border-r border-gray-200 p-4 overflow-y-auto" data-tutorial-target="toolbar">
46
- <h2 className="text-lg font-semibold text-gray-900 mb-4">Layers & Nodes</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  <div className="space-y-2">
48
  {toolbarItems.map((category) => {
49
  const Icon = category.icon
50
  const isExpanded = expandedCategory === category.category
51
 
52
  return (
53
- <div key={category.category} className="border border-gray-200 rounded-lg overflow-hidden">
54
  <button
55
  onClick={() => setExpandedCategory(isExpanded ? null : category.category)}
56
- className="w-full px-4 py-3 flex items-center justify-between hover:bg-gray-50 transition-colors"
57
  >
58
  <div className="flex items-center space-x-3">
59
- <Icon className={`w-5 h-5 ${category.color}`} />
60
- <span className="font-medium text-gray-900">{category.category}</span>
61
- </div>
62
- <ChevronDown className={`w-4 h-4 text-gray-400 transition-transform ${isExpanded ? 'rotate-180' : ''}`} />
63
- </button>
64
-
65
- {isExpanded && (
66
- <div className="bg-gray-50 p-2 space-y-1">
67
- {category.items.map((item) => (
68
- <div
69
- key={item}
70
- draggable
71
- onDragStart={(e) => handleDragStart(e, item)}
72
- className="px-4 py-2 text-sm text-gray-700 hover:bg-white rounded-lg cursor-move transition-colors border border-transparent hover:border-gray-300"
73
- >
74
- {item}
75
- </div>
76
- ))}
77
- </div>
78
- )}
79
- </div>
80
- )
81
- })}
82
- </div>
83
-
84
- <div className="mt-6 p-4 bg-blue-50 rounded-lg border border-blue-200">
85
- <h3 className="font-semibold text-blue-900 mb-2">Quick Tip</h3>
86
- <p className="text-sm text-blue-800">Drag any layer onto the canvas to start building your architecture!</p>
87
- </div>
88
- </div>
89
- )
90
- }
 
1
  import { useState } from 'react'
2
+ import {
3
+ Database, Layers, Activity, Filter, Settings, ChevronDown,
4
+ Image, Type, Hash, Share2, Brain, Zap, BarChart3
5
+ } from 'lucide-react'
6
 
7
  const toolbarItems = [
8
  {
9
  category: 'Input',
10
  icon: Database,
11
  color: 'text-blue-600',
12
+ bgColor: 'bg-blue-50',
13
+ items: [
14
+ { name: 'Input Layer', icon: Image, desc: 'Input data layer' },
15
+ { name: 'Embedding', icon: Type, desc: 'Embedding layer' },
16
+ { name: 'Data Augmentation', icon: Zap, desc: 'Augment training data' }
17
+ ]
18
  },
19
  {
20
  category: 'Core',
21
  icon: Layers,
22
  color: 'text-purple-600',
23
+ bgColor: 'bg-purple-50',
24
+ items: [
25
+ { name: 'Dense', icon: BarChart3, desc: 'Fully connected layer' },
26
+ { name: 'Convolution', icon: Filter, desc: 'Conv2D layer' },
27
+ { name: 'Recurrent', icon: Share2, desc: 'LSTM/GRU layer' },
28
+ { name: 'Transformer', icon: Brain, desc: 'Attention layer' }
29
+ ]
30
  },
31
  {
32
  category: 'Activation',
33
  icon: Activity,
34
  color: 'text-green-600',
35
+ bgColor: 'bg-green-50',
36
+ items: [
37
+ { name: 'ReLU', icon: Zap, desc: 'Rectified Linear Unit' },
38
+ { name: 'Sigmoid', icon: Activity, desc: 'Sigmoid activation' },
39
+ { name: 'Tanh', icon: BarChart3, desc: 'Hyperbolic tangent' },
40
+ { name: 'Softmax', icon: Layers, desc: 'Softmax activation' }
41
+ ]
42
  },
43
  {
44
  category: 'Regularization',
45
  icon: Filter,
46
  color: 'text-orange-600',
47
+ bgColor: 'bg-orange-50',
48
+ items: [
49
+ { name: 'Dropout', icon: Filter, desc: 'Dropout regularization' },
50
+ { name: 'Batch Norm', icon: BarChart3, desc: 'Batch normalization' },
51
+ { name: 'Layer Norm', icon: Layers, desc: 'Layer normalization' }
52
+ ]
53
  },
54
  {
55
  category: 'Output',
56
  icon: Settings,
57
  color: 'text-red-600',
58
+ bgColor: 'bg-red-50',
59
+ items: [
60
+ { name: 'Output Layer', icon: Share2, desc: 'Final output layer' },
61
+ { name: 'Loss Function', icon: Activity, desc: 'Loss/metric' },
62
+ { name: 'Metric', icon: BarChart3, desc: 'Evaluation metric' }
63
+ ]
64
  }
65
  ]
66
 
67
+ export default function Toolbar({ sidebarOpen, setSidebarOpen }) {
68
+ const [expandedCategory, setExpandedCategory] = useState('Core')
69
 
70
  const handleDragStart = (e, itemType) => {
71
  e.dataTransfer.setData('node-type', itemType)
72
+ e.dataTransfer.effectAllowed = 'copy'
73
  }
74
 
75
  return (
76
+ <>
77
+ {/* Mobile Sidebar */}
78
+ <div className={`fixed inset-0 z-40 lg:relative lg:inset-auto ${sidebarOpen ? 'block' : 'hidden'}`}>
79
+ <div className="absolute inset-0 bg-black bg-opacity-50 lg:hidden" onClick={() => setSidebarOpen(false)} />
80
+ <div className="absolute left-0 top-0 h-full w-64 bg-white border-r border-gray-200 p-4 overflow-y-auto z-50 lg:relative lg:z-auto">
81
+ <ToolbarContent
82
+ expandedCategory={expandedCategory}
83
+ setExpandedCategory={setExpandedCategory}
84
+ handleDragStart={handleDragStart}
85
+ />
86
+ </div>
87
+ </div>
88
+
89
+ {/* Desktop Toolbar */}
90
+ <div className="hidden lg:block w-64 bg-white border-r border-gray-200 p-4 overflow-y-auto" data-tutorial-target="toolbar">
91
+ <ToolbarContent
92
+ expandedCategory={expandedCategory}
93
+ setExpandedCategory={setExpandedCategory}
94
+ handleDragStart={handleDragStart}
95
+ />
96
+ </div>
97
+ </>
98
+ )
99
+ }
100
+
101
+ function ToolbarContent({ expandedCategory, setExpandedCategory, handleDragStart }) {
102
+ return (
103
+ <>
104
+ <div className="flex items-center justify-between mb-4">
105
+ <h2 className="text-lg font-semibold text-gray-900">Layers & Nodes</h2>
106
+ <div className="w-2 h-2 bg-green-500 rounded-full animate-pulse" />
107
+ </div>
108
  <div className="space-y-2">
109
  {toolbarItems.map((category) => {
110
  const Icon = category.icon
111
  const isExpanded = expandedCategory === category.category
112
 
113
  return (
114
+ <div key={category.category} className="border border-gray-200 rounded-lg overflow-hidden transition-all">
115
  <button
116
  onClick={() => setExpandedCategory(isExpanded ? null : category.category)}
117
+ className={`w-full px-4 py-3 flex items-center justify-between transition-colors ${isExpanded ? category.bgColor : 'hover:bg-gray-50'}`}
118
  >
119
  <div className="flex items-center space-x-3">
120
+ <Icon className={`w-5 h