|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { ComponentPalette } from './ComponentPalette'; |
| 3 | +import { ComponentTree } from './ComponentTree'; |
| 4 | +import { cn } from '@object-ui/components'; |
| 5 | +import { Layers, Box } from 'lucide-react'; |
| 6 | + |
| 7 | +interface LeftSidebarProps { |
| 8 | + className?: string; |
| 9 | +} |
| 10 | + |
| 11 | +type TabType = 'palette' | 'tree'; |
| 12 | + |
| 13 | +export const LeftSidebar: React.FC<LeftSidebarProps> = React.memo(({ className }) => { |
| 14 | + const [activeTab, setActiveTab] = useState<TabType>('palette'); |
| 15 | + |
| 16 | + return ( |
| 17 | + <div className={cn("flex flex-col h-full bg-white w-72", className)}> |
| 18 | + {/* Tab Headers */} |
| 19 | + <div className="flex border-b bg-gray-50/50 shrink-0"> |
| 20 | + <button |
| 21 | + onClick={() => setActiveTab('palette')} |
| 22 | + className={cn( |
| 23 | + "flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium transition-all relative", |
| 24 | + activeTab === 'palette' |
| 25 | + ? "text-blue-600 bg-white border-b-2 border-blue-600" |
| 26 | + : "text-gray-600 hover:text-gray-900 hover:bg-gray-100/50" |
| 27 | + )} |
| 28 | + > |
| 29 | + <Box size={16} /> |
| 30 | + <span>Components</span> |
| 31 | + </button> |
| 32 | + <button |
| 33 | + onClick={() => setActiveTab('tree')} |
| 34 | + className={cn( |
| 35 | + "flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-medium transition-all relative", |
| 36 | + activeTab === 'tree' |
| 37 | + ? "text-blue-600 bg-white border-b-2 border-blue-600" |
| 38 | + : "text-gray-600 hover:text-gray-900 hover:bg-gray-100/50" |
| 39 | + )} |
| 40 | + > |
| 41 | + <Layers size={16} /> |
| 42 | + <span>Tree</span> |
| 43 | + </button> |
| 44 | + </div> |
| 45 | + |
| 46 | + {/* Tab Content */} |
| 47 | + <div className="flex-1 overflow-hidden"> |
| 48 | + {activeTab === 'palette' ? ( |
| 49 | + <ComponentPalette className="h-full" /> |
| 50 | + ) : ( |
| 51 | + <ComponentTree className="h-full" /> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + ); |
| 56 | +}); |
| 57 | + |
| 58 | +LeftSidebar.displayName = 'LeftSidebar'; |
0 commit comments