Skip to content

Commit 7b779dc

Browse files
committed
refactor: separate Editor into modular components and custom hooks for better maintainability
1 parent a0a6641 commit 7b779dc

9 files changed

+748
-577
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {ComponentData} from '../types';
2+
3+
interface ComponentsSidebarProps {
4+
components: ComponentData[];
5+
onAddElement: (type: string) => void;
6+
}
7+
8+
export function ComponentsSidebar({components, onAddElement}: ComponentsSidebarProps) {
9+
return (
10+
<div className="w-64 border-r bg-white">
11+
<div className="p-4">
12+
<h2 className="font-semibold text-sm text-gray-700 mb-4">Components</h2>
13+
<div className="space-y-2">
14+
{components.map(component => (
15+
<button
16+
key={component.id}
17+
onClick={() => onAddElement(component.id)}
18+
className="w-full p-3 flex items-center space-x-3 rounded hover:bg-gray-50 border"
19+
>
20+
<span className="w-6 h-6 flex items-center justify-center bg-gray-100 rounded">
21+
{component.icon}
22+
</span>
23+
<span className="text-sm">{component.name}</span>
24+
</button>
25+
))}
26+
</div>
27+
</div>
28+
</div>
29+
);
30+
}

0 commit comments

Comments
 (0)