agentsclimarketplace

Storybook

Skill DaleStudy/skills/skills/storybook

๐Ÿ› ๏ธ ์—์ด์ „ํŠธ ์Šคํ‚ฌ

Install
npx -y skills add DaleStudy/skills --skill storybook

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Storybook ์Šคํ† ๋ฆฌ ์ž‘์„ฑ ๋ฐ CSF 3.0 ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค ์Šคํ‚ฌ. ๋‹ค์Œ ์ƒํ™ฉ์—์„œ ์‚ฌ์šฉ: (1) ์ƒˆ ์Šคํ† ๋ฆฌ ํŒŒ์ผ(.stories.tsx, .stories.ts) ์ž‘์„ฑ ์‹œ, (2) ๊ธฐ์กด ์Šคํ† ๋ฆฌ ์ˆ˜์ • ์‹œ, (3) Args, Decorators, Parameters ์„ค์ • ์‹œ, (4) Storybook ์„ค์ • ํŒŒ์ผ(.storybook/) ์ž‘์—… ์‹œ, (5) 'story', 'stories', 'storybook', 'CSF' ํ‚ค์›Œ๋“œ๊ฐ€ ํฌํ•จ๋œ ์ž‘์—… ์‹œ

The file declares its own license as MIT. That is the authorโ€™s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

10.1 KB, as published. Nobody here has run it

Storybook

๋ชจ๋ฒ” ๊ด€๋ก€

1. CSF 3.0 ํ˜•์‹ ์‚ฌ์šฉ

์ตœ์‹  Component Story Format 3.0 ์‚ฌ์šฉ. ๋” ๊ฐ„๊ฒฐํ•˜๊ณ  ํƒ€์ž… ์•ˆ์ „.

// โŒ CSF 2.0 (๊ตฌํ˜•)
export default {
  title: 'Components/Button',
  component: Button,
};

export const Primary = () => <Button variant="primary">Click me</Button>;

// โœ… CSF 3.0 (๊ถŒ์žฅ)
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';

const meta = {
  component: Button,
  tags: ['autodocs'], // ์ž๋™ ๋ฌธ์„œ ์ƒ์„ฑ
  args: {
    variant: 'primary',
    children: 'Click me',
  },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Primary: Story = {};

export const Secondary: Story = {
  args: {
    variant: 'secondary',
  },
};

2. Args ๊ธฐ๋ฐ˜ ์Šคํ† ๋ฆฌ ์ž‘์„ฑ

์ปดํฌ๋„ŒํŠธ Props๋ฅผ Args๋กœ ์ •์˜ํ•˜์—ฌ Controls ํŒจ๋„์—์„œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒํ•˜๊ฒŒ ์กฐ์ž‘ ๊ฐ€๋Šฅ.

  • ๊ธฐ๋ณธ๊ฐ’์€ args์—์„œ ์„ ์–ธ (โŒ argTypes.defaultValue ์‚ฌ์šฉ ๊ธˆ์ง€). Meta์˜ args์— ๊ธฐ๋ณธ๊ฐ’์„ ๋‘๋ฉด Controls ํŒจ๋„์—์„œ ์ž๋™์œผ๋กœ ํ•ด๋‹น ๊ฐ’์ด ์„ ํƒ๋จ
  • ์—ฌ๋Ÿฌ ์Šคํ† ๋ฆฌ์— ๊ณตํ†ต์œผ๋กœ ํ•„์š”ํ•œ args๋Š” Meta(์ปดํฌ๋„ŒํŠธ) ์ˆ˜์ค€์—์„œ ์„ ์–ธํ•˜๊ณ , ๊ฐœ๋ณ„ ์Šคํ† ๋ฆฌ์—์„œ๋Š” ์ฐจ์ด์ ๋งŒ ์˜ค๋ฒ„๋ผ์ด๋“œ
// โŒ ํ•˜๋“œ์ฝ”๋”ฉ๋œ Props
export const Disabled: Story = {
  render: () => <Button disabled>Disabled</Button>,
};

// โŒ ์—ฌ๋Ÿฌ ์Šคํ† ๋ฆฌ์—์„œ ๊ฐ™์€ args ์ค‘๋ณต
export const Primary: Story = {
  args: { children: 'Click me', variant: 'primary' },
};
export const Secondary: Story = {
  args: { children: 'Click me', variant: 'secondary' },
};

// โœ… Meta์—์„œ ๊ณตํ†ต args ์„ ์–ธ, ์Šคํ† ๋ฆฌ์—์„œ ์ฐจ์ด์ ๋งŒ ์˜ค๋ฒ„๋ผ์ด๋“œ
const meta = {
  component: Button,
  args: {
    children: 'Click me',
    variant: 'primary',
  },
} satisfies Meta<typeof Button>;

export const Primary: Story = {};

export const Secondary: Story = {
  args: { variant: 'secondary' },
};

export const Disabled: Story = {
  args: { disabled: true },
};

3. title ์ƒ๋žต โ€” ํŒŒ์ผ ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ ์ž๋™ ์ถ”๋ก 

title์„ ๋ฌธ์ž์—ด๋กœ ์ง์ ‘ ๋ช…์‹œํ•˜๋ฉด ํƒ€์ž… ์•ˆ์ „ํ•˜์ง€ ์•Š๊ณ , ์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„/๊ฒฝ๋กœ ๋ณ€๊ฒฝ ์‹œ ์‹ฑํฌ๊ฐ€ ๊นจ์ง€๊ธฐ ์‰ฌ์›€. Storybook์€ ํŒŒ์ผ ๊ฒฝ๋กœ์—์„œ ์‚ฌ์ด๋“œ๋ฐ” ๊ณ„์ธต์„ ์ž๋™ ์ถ”๋ก ํ•˜๋ฏ€๋กœ title ์ƒ๋žต.

// โŒ title ์ง์ ‘ ๋ช…์‹œ โ€” ํƒ€์ž… ์•ˆ์ „ํ•˜์ง€ ์•Š๊ณ  ์‹ฑํฌ ๊นจ์ง ์œ„ํ—˜
const meta = {
  title: 'Components/Button',
  component: Button,
} satisfies Meta<typeof Button>;

// โœ… title ์ƒ๋žต โ€” ํŒŒ์ผ ๊ฒฝ๋กœ์—์„œ ์ž๋™ ์ถ”๋ก 
const meta = {
  component: Button,
} satisfies Meta<typeof Button>;

4. ํƒ€์ž… ์•ˆ์ „ํ•œ Meta ์ •์˜

satisfies ํ‚ค์›Œ๋“œ๋กœ ํƒ€์ž… ์ฒดํฌ์™€ ํƒ€์ž… ์ถ”๋ก  ๋™์‹œ ํ™œ์šฉ.

// โŒ ํƒ€์ž… ์ถ”๋ก  ๋ถˆ๊ฐ€
const meta: Meta<typeof Button> = {
  component: Button,
};

// โœ… ํƒ€์ž… ์ฒดํฌ์™€ ์ถ”๋ก  ๋ชจ๋‘ ๊ฐ€๋Šฅ
const meta = {
  component: Button,
  args: {
    size: 'md',
    variant: 'primary',
  },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

5. Decorators๋กœ ์ปจํ…์ŠคํŠธ ์ œ๊ณต

๊ณตํ†ต ๋ž˜ํผ๋‚˜ Provider๋ฅผ Decorator๋กœ ์ ์šฉ.

// ๊ฐœ๋ณ„ ์Šคํ† ๋ฆฌ์— Decorator ์ ์šฉ
export const WithTheme: Story = {
  decorators: [
    (Story) => (
      <ThemeProvider theme="dark">
        <Story />
      </ThemeProvider>
    ),
  ],
};

// ๋ชจ๋“  ์Šคํ† ๋ฆฌ์— Decorator ์ ์šฉ
const meta = {
  component: Button,
  decorators: [
    (Story) => (
      <div style={{ padding: '3rem' }}>
        <Story />
      </div>
    ),
  ],
} satisfies Meta<typeof Button>;

6. Parameters๋กœ ๋™์ž‘ ์ปค์Šคํ„ฐ๋งˆ์ด์ฆˆ

const meta = {
  component: Button,
  parameters: {
    layout: 'centered', // ์Šคํ† ๋ฆฌ๋ฅผ ์ค‘์•™ ์ •๋ ฌ
    backgrounds: {
      default: 'light',
      values: [
        { name: 'light', value: '#ffffff' },
        { name: 'dark', value: '#000000' },
      ],
    },
  },
} satisfies Meta<typeof Button>;

// ๊ฐœ๋ณ„ ์Šคํ† ๋ฆฌ์—์„œ ์˜ค๋ฒ„๋ผ์ด๋“œ
export const OnDark: Story = {
  parameters: {
    backgrounds: { default: 'dark' },
  },
};

7. ArgTypes โ€” ์ž๋™ ์ถ”๋ก  ์šฐ์„ , ์ˆ˜๋™ ์ง€์ • ์ตœ์†Œํ™”

Storybook์€ ์ปดํฌ๋„ŒํŠธ ํ•จ์ˆ˜์˜ TypeScript ํƒ€์ž…์—์„œ ์ตœ์ ์˜ argType์„ ์ž๋™ ์ ์šฉํ•จ. ์ˆ˜๋™์œผ๋กœ ๋ฎ์–ด์“ฐ๋ฉด ์ปดํฌ๋„ŒํŠธ ํƒ€์ž… ๋ณ€๊ฒฝ ์‹œ๋งˆ๋‹ค argType ์‹ฑํฌ๋ฅผ ๋งž์ถฐ์•ผ ํ•˜๋ฏ€๋กœ ํƒ€๋‹นํ•œ ์ด์œ  ์—†์ด argType์„ ์ง์ ‘ ์ง€์ •ํ•˜์ง€ ์•Š์Œ.

์ˆ˜๋™ ์ง€์ •์ด ํƒ€๋‹นํ•œ ๊ฒฝ์šฐ:

  • ReactNode ํƒ€์ž…์ธ๋ฐ Controls์—์„œ ํ…์ŠคํŠธ ์ž…๋ ฅ์ด ํ•„์š”ํ•  ๋•Œ โ†’ control: 'text'
  • Compound pattern (์ปดํฌ๋„ŒํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๊ฐœ export) โ†’ argTypes๋กœ ๋ช…์‹œ
  • ํŠน์ • ์Šคํ† ๋ฆฌ์—์„œ ํ•ญ์ƒ ๊ณ ์ •๋˜์–ด์•ผ ํ•˜๋Š” prop โ†’ control: false
// โŒ ๋ถˆํ•„์š”ํ•œ argType ์ˆ˜๋™ ์ง€์ • โ€” ํƒ€์ž… ๋ณ€๊ฒฝ ์‹œ ์‹ฑํฌ ๊นจ์ง
const meta = {
  component: Button,
  argTypes: {
    variant: {
      control: 'select',
      options: ['primary', 'secondary', 'tertiary'],
    },
    size: {
      control: 'radio',
      options: ['sm', 'md', 'lg'],
    },
    disabled: {
      control: 'boolean',
    },
  },
} satisfies Meta<typeof Button>;

// โœ… ์ž๋™ ์ถ”๋ก ์— ๋งก๊ธฐ๊ณ , ํ•„์š”ํ•œ ๊ฒฝ์šฐ๋งŒ ์ˆ˜๋™ ์ง€์ •
const meta = {
  component: Button,
  argTypes: {
    // ReactNode ํƒ€์ž…์ด์ง€๋งŒ ํ…์ŠคํŠธ ์ž…๋ ฅ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ
    children: { control: 'text' },
  },
} satisfies Meta<typeof Button>;

// โœ… ํŠน์ • ์Šคํ† ๋ฆฌ์—์„œ prop์„ ๊ณ ์ •ํ•  ๋•Œ โ€” control: false
export const Horizontal: Story = {
  args: { orientation: 'horizontal' },
  argTypes: {
    orientation: { control: false }, // ์ด ์Šคํ† ๋ฆฌ์—์„œ๋Š” ํ•ญ์ƒ horizontal
  },
};

๊ถŒ์žฅ ์Šคํ† ๋ฆฌ ๊ตฌ์กฐ

import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';

// 1. Meta ์ •์˜ โ€” title ์ƒ๋žต, ๊ณตํ†ต args ์„ ์–ธ, argTypes๋Š” ์ž๋™ ์ถ”๋ก ์— ์œ„์ž„
const meta = {
  component: Button,
  tags: ['autodocs'],
  parameters: {
    layout: 'centered',
  },
  args: {
    children: 'Button',
    size: 'md',
    variant: 'primary',
  },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

// 2. ๊ธฐ๋ณธ ์Šคํ† ๋ฆฌ โ€” Meta args๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
export const Primary: Story = {};

// 3. ๋ณ€ํ˜• ์Šคํ† ๋ฆฌ๋“ค โ€” ์ฐจ์ด์ ๋งŒ ์˜ค๋ฒ„๋ผ์ด๋“œ
export const Secondary: Story = {
  args: {
    variant: 'secondary',
  },
};

export const Disabled: Story = {
  args: {
    disabled: true,
  },
};

// 4. prop ๊ณ ์ •์ด ํ•„์š”ํ•œ ์Šคํ† ๋ฆฌ โ€” control: false ์‚ฌ์šฉ
export const Horizontal: Story = {
  args: { orientation: 'horizontal' },
  argTypes: {
    orientation: { control: false },
  },
};

// 5. ๋ณต์žกํ•œ ์ƒํƒœ๋‚˜ ์ปจํ…์ŠคํŠธ๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ
export const WithCustomTheme: Story = {
  decorators: [
    (Story) => (
      <ThemeProvider theme="custom">
        <Story />
      </ThemeProvider>
    ),
  ],
};

ArgTypes ์ˆ˜๋™ ์ง€์ •์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ฐธ๊ณ 

์›์น™: ๋Œ€๋ถ€๋ถ„์˜ argType์€ Storybook์ด ์ปดํฌ๋„ŒํŠธ ํƒ€์ž…์—์„œ ์ž๋™ ์ถ”๋ก . ์•„๋ž˜๋Š” ์ž๋™ ์ถ”๋ก ์ด ๋ถ€์ ์ ˆํ•  ๋•Œ๋งŒ ์‚ฌ์šฉ.

๊ธฐ๋ณธ๊ฐ’์€ argTypes.defaultValue๊ฐ€ ์•„๋‹Œ args์—์„œ ์„ ์–ธ.

argTypes: {
  // ReactNode ํƒ€์ž…์ด์ง€๋งŒ ํ…์ŠคํŠธ ์ž…๋ ฅ์ด ํ•„์š”ํ•  ๋•Œ
  children: { control: 'text' },

  // Range slider (์ž๋™ ์ถ”๋ก ์ด ์ ์ ˆํ•˜์ง€ ์•Š์„ ๋•Œ)
  opacity: {
    control: { type: 'range', min: 0, max: 1, step: 0.1 },
  },

  // Action logger (์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ)
  onClick: { action: 'clicked' },

  // Control ๋น„ํ™œ์„ฑํ™” (ํŠน์ • ์Šคํ† ๋ฆฌ์—์„œ prop ๊ณ ์ •)
  orientation: { control: false },
}

์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” Parameters

parameters: {
  // ๋ ˆ์ด์•„์›ƒ ์„ค์ •
  layout: 'centered' | 'fullscreen' | 'padded',

  // ๋ฐฐ๊ฒฝ ์„ค์ •
  backgrounds: {
    default: 'light',
    values: [
      { name: 'light', value: '#ffffff' },
      { name: 'dark', value: '#333333' },
    ],
  },

  // Actions ํŒจ๋„ ์„ค์ •
  actions: {
    argTypesRegex: '^on[A-Z].*', // on์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” Props ์ž๋™ ๊ฐ์ง€
  },

  // Docs ์„ค์ •
  docs: {
    description: {
      component: '๋ฒ„ํŠผ ์ปดํฌ๋„ŒํŠธ ์ƒ์„ธ ์„ค๋ช…',
    },
  },
}

Decorators ํŒจํ„ด

// 1. ์Šคํƒ€์ผ ๋ž˜ํผ
(Story) => (
  <div style={{ padding: '3rem' }}>
    <Story />
  </div>
)

// 2. Theme Provider
(Story) => (
  <ThemeProvider theme="dark">
    <Story />
  </ThemeProvider>
)

// 3. Router Provider (React Router ์‚ฌ์šฉ ์‹œ)
(Story) => (
  <MemoryRouter initialEntries={['/']}>
    <Story />
  </MemoryRouter>
)

// 4. ๋‹ค๊ตญ์–ด Provider
(Story) => (
  <I18nProvider locale="ko">
    <Story />
  </I18nProvider>
)

// 5. ์ „์—ญ ์ƒํƒœ Provider
(Story) => (
  <Provider store={mockStore}>
    <Story />
  </Provider>
)

ํŒŒ์ผ ๋ช…๋ช… ๊ทœ์น™

Component.tsx           # ์ปดํฌ๋„ŒํŠธ ๊ตฌํ˜„
Component.stories.tsx   # ์Šคํ† ๋ฆฌ ํŒŒ์ผ (๊ฐ™์€ ๋””๋ ‰ํ† ๋ฆฌ)
Component.test.tsx      # ํ…Œ์ŠคํŠธ ํŒŒ์ผ

Storybook ์„ค์ • ํŒŒ์ผ

// .storybook/main.ts
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
  stories: ['../src/**/*.stories.@(ts|tsx)'],
  addons: [
    '@storybook/addon-essentials', // Controls, Actions, Docs ๋“ฑ
    '@storybook/addon-interactions', // Play functions
  ],
  framework: {
    name: '@storybook/react-vite',
    options: {},
  },
};

export default config;
// .storybook/preview.ts
import type { Preview } from '@storybook/react';

const preview: Preview = {
  parameters: {
    actions: { argTypesRegex: '^on[A-Z].*' },
    controls: {
      matchers: {
        color: /(background|color)$/i,
        date: /Date$/,
      },
    },
  },
  // ๋ชจ๋“  ์Šคํ† ๋ฆฌ์— ์ ์šฉ๋  ์ „์—ญ Decorators
  decorators: [
    (Story) => (
      <div style={{ fontFamily: 'Arial, sans-serif' }}>
        <Story />
      </div>
    ),
  ],
};

export default preview;

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.