11'use client'
22
33import { useRef } from 'react'
4- import { Button } from '@/components/emcn'
5- import { BubbleChatPreview , MoreHorizontal , Play , Rocket } from '@/components/emcn/icons'
4+ import { BubbleChatPreview , Button , MoreHorizontal , Play , Rocket } from '@/components/emcn'
5+ import { usePanelStore } from '@/stores/panel-new/store'
6+ import type { PanelTab } from '@/stores/panel-new/types'
7+ import { Copilot , Design } from './components'
68import { usePanelResize } from './hooks/use-panel-resize'
79
810/**
9- * Panel component with resizable width that persists across page refreshes.
11+ * Panel component with resizable width and tab navigation that persists across page refreshes.
1012 *
1113 * Uses a CSS-based approach to prevent hydration mismatches:
1214 * 1. Width is controlled by CSS variable (--panel-width)
@@ -19,10 +21,32 @@ import { usePanelResize } from './hooks/use-panel-resize'
1921 */
2022export function Panel ( ) {
2123 const panelRef = useRef < HTMLElement > ( null )
24+ const { activeTab, setActiveTab } = usePanelStore ( )
2225
2326 // Panel resize hook
2427 const { handleMouseDown } = usePanelResize ( )
2528
29+ /**
30+ * Renders the active tab content based on the current selection
31+ */
32+ const renderTabContent = ( ) => {
33+ switch ( activeTab ) {
34+ case 'copilot' :
35+ return < Copilot />
36+ case 'design' :
37+ return < Design />
38+ default :
39+ return < Copilot />
40+ }
41+ }
42+
43+ /**
44+ * Handles tab click events
45+ */
46+ const handleTabClick = ( tab : PanelTab ) => {
47+ setActiveTab ( tab )
48+ }
49+
2650 return (
2751 < >
2852 < aside
@@ -42,7 +66,7 @@ export function Panel() {
4266 </ Button >
4367 </ div >
4468 < div className = 'flex gap-[4px]' >
45- < Button className = 'h-[32px] gap-[8px] px-[10px]' >
69+ < Button className = 'h-[32px] gap-[8px] px-[10px]' variant = 'active' >
4670 < Rocket className = 'h-[13px] w-[13px]' />
4771 Deploy
4872 </ Button >
@@ -55,16 +79,24 @@ export function Panel() {
5579
5680 { /* Tabs */ }
5781 < div className = 'flex flex-shrink-0 items-center gap-[4px] px-[8px] pt-[14px]' >
58- < Button className = 'h-[30px] gap-[8px] px-[10px]' variant = 'ghost' >
59- Design
60- </ Button >
61- < Button className = 'h-[30px] gap-[8px] px-[10px]' variant = 'active' >
82+ < Button
83+ className = 'px-[8px] py-[5px] text-[12.5px] hover:bg-[#353535] hover:text-[#E6E6E6] dark:hover:bg-[#353535] dark:hover:text-[#E6E6E6]'
84+ variant = { activeTab === 'copilot' ? 'active' : 'ghost' }
85+ onClick = { ( ) => handleTabClick ( 'copilot' ) }
86+ >
6287 Copilot
6388 </ Button >
64- < Button className = 'h-[30px] gap-[8px] px-[10px]' variant = 'ghost' >
65- Variables
89+ < Button
90+ className = 'px-[8px] py-[5px] text-[12.5px] hover:bg-[#353535] hover:text-[#E6E6E6] dark:hover:bg-[#353535] dark:hover:text-[#E6E6E6]'
91+ variant = { activeTab === 'design' ? 'active' : 'ghost' }
92+ onClick = { ( ) => handleTabClick ( 'design' ) }
93+ >
94+ Design
6695 </ Button >
6796 </ div >
97+
98+ { /* Tab Content */ }
99+ < div className = 'flex-1 pt-[12px]' > { renderTabContent ( ) } </ div >
68100 </ div >
69101 </ aside >
70102
0 commit comments