diff --git a/src/components/ComponentTreeViewer.tsx b/src/components/ComponentTreeViewer.tsx index ef9d3ac..6f2fea2 100644 --- a/src/components/ComponentTreeViewer.tsx +++ b/src/components/ComponentTreeViewer.tsx @@ -7,15 +7,55 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { ScrollArea } from '@/components/ui/scroll-area' import { Separator } from '@/components/ui/separator' import { toast } from 'sonner' -import { - Cube, - TreeStructure, - ArrowsClockwise, - CheckCircle, +import { + Cube, + TreeStructure, + ArrowsClockwise, + CheckCircle, Warning, Package, - Stack + Stack, } from '@phosphor-icons/react' +import componentTreeCopy from '@/data/component-tree-viewer.json' +import { ComponentNode, ComponentTree } from '@/types/project' + +type ComponentTreeCategory = 'molecule' | 'organism' + +type ComponentTreeWithCategory = ComponentTree & { + category?: ComponentTreeCategory +} + +type ComponentTreeHeaderProps = { + isLoaded: boolean + isLoading: boolean + totalTrees: number + onReload: () => void +} + +type ComponentTreeStatusProps = { + error: Error | null +} + +type ComponentTreeListProps = { + trees: ComponentTreeWithCategory[] + selectedTreeId: string | null + onSelect: (id: string) => void + variant: 'molecules' | 'organisms' | 'all' +} + +type ComponentTreeDetailProps = { + tree?: ComponentTree +} + +const formatDate = (timestamp: number) => new Date(timestamp).toLocaleDateString() + +const getCategoryLabel = (category?: ComponentTreeCategory) => { + if (!category) { + return '' + } + + return componentTreeCopy.categories[category] ?? category +} export function ComponentTreeViewer() { const { @@ -33,9 +73,9 @@ export function ComponentTreeViewer() { const handleReload = async () => { try { await reloadFromJSON() - toast.success('Component trees reloaded from JSON') + toast.success(componentTreeCopy.toast.reloadSuccess) } catch (err) { - toast.error('Failed to reload component trees') + toast.error(componentTreeCopy.toast.reloadError) } } @@ -43,64 +83,33 @@ export function ComponentTreeViewer() { return (
- Molecules and organisms loaded from JSON -
-Error loading component trees
-{error.message}
-Select a tree to view details
-Select a tree to view details
-Select a tree to view details
-+ {componentTreeCopy.header.subtitle} +
+{componentTreeCopy.status.errorTitle}
+{error.message}
+{componentTreeCopy.status.selectPrompt}
+{tree.description}
-{tree.description}
+