Upload components/Toolbar.js with huggingface_hub
Browse files- components/Toolbar.js +90 -0
components/Toolbar.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|