From 7311c354d554a57ed7adea140e5a1007192d8645 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 18 Jan 2026 00:35:48 +0000 Subject: [PATCH] Refactor Storybook designer copy --- src/components/StorybookDesigner.tsx | 539 ++++++++++++++------------- src/data/storybook-designer.json | 43 +++ 2 files changed, 325 insertions(+), 257 deletions(-) create mode 100644 src/data/storybook-designer.json diff --git a/src/components/StorybookDesigner.tsx b/src/components/StorybookDesigner.tsx index a878c02..0973777 100644 --- a/src/components/StorybookDesigner.tsx +++ b/src/components/StorybookDesigner.tsx @@ -11,314 +11,339 @@ import { Textarea } from '@/components/ui/textarea' import { Plus, Trash, BookOpen, Sparkle } from '@phosphor-icons/react' import { toast } from 'sonner' import { Badge } from '@/components/ui/badge' +import copy from '@/data/storybook-designer.json' interface StorybookDesignerProps { stories: StorybookStory[] onStoriesChange: (stories: StorybookStory[]) => void } -export function StorybookDesigner({ stories, onStoriesChange }: StorybookDesignerProps) { - const [selectedStoryId, setSelectedStoryId] = useState(stories[0]?.id || null) +interface StoryListPanelProps { + stories: StorybookStory[] + categories: string[] + selectedStoryId: string | null + onSelectStory: (storyId: string) => void + onAddStory: () => void + onGenerateWithAI: () => void + onDeleteStory: (storyId: string) => void +} + +interface StoryDetailsEditorProps { + selectedStory: StorybookStory + onUpdateStory: (storyId: string, updates: Partial) => void +} + +interface StoryArgsEditorProps { + selectedStory: StorybookStory + onUpdateStory: (storyId: string, updates: Partial) => void +} + +const parseArgValue = (value: string) => { + try { + return JSON.parse(value) + } catch { + return value + } +} + +const StoryListPanel = ({ + stories, + categories, + selectedStoryId, + onSelectStory, + onAddStory, + onGenerateWithAI, + onDeleteStory +}: StoryListPanelProps) => ( +
+
+

{copy.list.title}

+
+ + +
+
+ + {categories.map(category => ( +
+
+ {category} +
+
+ {stories.filter(story => story.category === category).map(story => ( +
onSelectStory(story.id)} + > +
+
{story.componentName}
+
{story.storyName}
+
+ +
+ ))} +
+
+ ))} + {stories.length === 0 && ( +
+ {copy.list.empty} +
+ )} +
+
+) + +const StoryDetailsEditor = ({ selectedStory, onUpdateStory }: StoryDetailsEditorProps) => ( + + + {copy.editor.detailsTitle} + + +
+
+ + onUpdateStory(selectedStory.id, { componentName: event.target.value })} + placeholder={copy.editor.componentNamePlaceholder} + /> +
+
+ + onUpdateStory(selectedStory.id, { storyName: event.target.value })} + placeholder={copy.editor.storyNamePlaceholder} + /> +
+
+
+ + onUpdateStory(selectedStory.id, { category: event.target.value })} + placeholder={copy.editor.categoryPlaceholder} + /> +
+
+ +