"use client"; import { useState, type ReactNode } from 'react'; import { Search, Plus, RefreshCw, LayoutList, Map, Folder, ChevronDown, ChevronRight, Table2, BookOpen, Settings, PanelLeftClose, PanelLeftOpen, Sun, Moon, } from 'lucide-react'; import type { PaneType } from '../panes/types'; import type { FocusedSkill } from '@/types/skills'; import type { Theme } from '@/hooks/useTheme'; import type { ContextSummary } from '@/types/database'; interface LeftToolbarProps { onSearchClick: () => void; onAddStuffClick: () => void; onRefreshClick: () => void; visiblePaneCount: 1 | 2 | 3; onVisiblePaneCountChange: (count: 1 | 2 | 3) => void; onSettingsClick: () => void; onPaneTypeClick: (paneType: PaneType) => void; isExpanded: boolean; onToggleExpanded: () => void; openTabTypes: Set; activeTabType: PaneType | null; focusedSkill?: FocusedSkill | null; theme: Theme; onThemeToggle: () => void; contexts?: ContextSummary[]; onContextQuickSelect?: (contextId: number, contextName: string) => void; } const NAV_WIDTH_COLLAPSED = 50; const NAV_WIDTH_EXPANDED = 280; const PRIMARY_VIEW_ITEMS: Array<{ paneType: PaneType; label: string; icon: typeof LayoutList }> = [ { paneType: 'views', label: 'Nodes', icon: LayoutList }, { paneType: 'skills', label: 'Skills', icon: BookOpen }, { paneType: 'map', label: 'Map', icon: Map }, { paneType: 'table', label: 'Table', icon: Table2 }, ]; function NavButton({ icon: Icon, label, expanded, active, onClick, trailing, activeTone = 'neutral', title, }: { icon: typeof Search; label: string; expanded: boolean; active?: boolean; onClick: () => void; trailing?: ReactNode; activeTone?: 'neutral' | 'green'; title?: string; }) { const [hovered, setHovered] = useState(false); const activeColor = activeTone === 'green' ? 'var(--rah-accent-green)' : 'var(--rah-text-active)'; return ( ); } export default function LeftToolbar({ onSearchClick, onAddStuffClick, onRefreshClick, visiblePaneCount, onVisiblePaneCountChange, onSettingsClick, onPaneTypeClick, isExpanded, onToggleExpanded, openTabTypes, activeTabType, focusedSkill, theme, onThemeToggle, contexts = [], onContextQuickSelect, }: LeftToolbarProps) { const [contextsExpanded, setContextsExpanded] = useState(false); const [paneSelectorOpen, setPaneSelectorOpen] = useState(false); const renderPaneGlyph = (count: 1 | 2 | 3, active: boolean) => ( {Array.from({ length: count }).map((_, index) => ( ))} ); const renderPaneCountButton = (count: 1 | 2 | 3) => { const active = visiblePaneCount === count; return ( ); }; const renderPaneSelector = () => (
{paneSelectorOpen ? (
{([1, 2, 3] as const).map((count) => renderPaneCountButton(count))}
) : null}
); const renderActionButtons = () => (
); return (
{renderPaneSelector()}
{renderActionButtons()}
{PRIMARY_VIEW_ITEMS.map((item) => ( onPaneTypeClick(item.paneType)} activeTone="green" /> ))}
onPaneTypeClick('contexts')} activeTone="green" />
{isExpanded ? ( ) : null}
{isExpanded && contextsExpanded && contexts.length > 0 ? (
{contexts.map((context) => ( ))}
) : null}
); }