Skip to content

Quick Start: Storybook + App Integration โ€‹

๐ŸŒ Live Storybook (for stakeholders) โ€‹

View components online (no local setup needed):

For setup: See STORYBOOK_SETUP_GUIDE.md


โœ… Issues Fixed โ€‹

  1. Vim swap files removed - "Open in editor" should now work
  2. Controls enabled - All component stories now have interactive controls
  3. Component created - Button.jsx now exists as a reusable component
  4. App updated - Button component is now used in the home page

๐ŸŽฏ The Simple Answer โ€‹

Storybook doesn't create separate components - it DOCUMENTS the same components you use in your app.

Component (Button.jsx)
   โ”‚
   โ”œโ”€โ”€โ†’ imported by Story (Button.stories.jsx) โ†’ Shows in Storybook
   โ”‚
   โ””โ”€โ”€โ†’ imported by App (App.jsx) โ†’ Shows in your app

๐Ÿš€ See It In Action โ€‹

In Storybook (http://localhost:6007) โ€‹

  1. Click Components โ†’ Button โ†’ Primary
  2. Use the Controls panel to change text and variant
  3. Click "Open canvas in new tab" or "Open in editor" (now works!)

In Your App (http://localhost:5173) โ€‹

  1. Look at the home page
  2. See the same Button component working
  3. Click the buttons - they trigger alerts

In Your Code โ€‹

๐Ÿ“ Quick Reference โ€‹

To Create a New Component: โ€‹

jsx
// 1. Create the component
// src/components/MyComponent.jsx
export default function MyComponent({ prop1, prop2 }) {
  return <div>{prop1} - {prop2}</div>
}

// 2. Create the story
// src/components/MyComponent.stories.jsx
import MyComponent from './MyComponent'

export default {
  title: 'Components/MyComponent',
  component: MyComponent,
  argTypes: {
    prop1: { control: 'text' },
    prop2: { control: 'number' }
  }
}

export const Default = {
  args: { prop1: 'Hello', prop2: 42 }
}

// 3. Use in your app
// src/App.jsx (or anywhere)
import MyComponent from './components/MyComponent'

<MyComponent prop1="World" prop2={100} />

๐Ÿ”„ Development Cycle โ€‹

  1. Build in Storybook - Create/test component variants
  2. Save changes - Changes appear in BOTH Storybook and app instantly
  3. Use in app - Import and use wherever needed
  4. Iterate - Make changes, see updates everywhere

๐Ÿ› ๏ธ Current Running Services โ€‹

Both are using the SAME components from src/components/.

๐Ÿ“š More Details โ€‹

See STORYBOOK_WORKFLOW.md for the complete explanation.

Built with VitePress