CSF3

CSF๋ž€?

'Component Story Format'(CSF)๋Š” ์ปดํฌ๋„ŒํŠธ์˜ ์Šคํ† ๋ฆฌ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

Storybook v7 ๋ถ€ํ„ฐ CSF3์„ ๊ธฐ๋ณธ ํฌ๋งท์œผ๋กœ ์ง€์›ํ•œ๋‹ค.

์ด์ „ ๋ฒ„์ „ ๋Œ€๋น„ํ•ด์„œ ์ƒ์šฉ๊ตฌ ์ฝ”๋“œ์˜ ์–‘์„ ํฌ๊ฒŒ ์ค„์—ฌ ๊ฐ„๊ฒฐํ•จ๊ณผ ์žฌ์‚ฌ์šฉ์„ฑ์ด ์ฆ๊ฐ€ํ•˜์—ฌ ์ƒ์‚ฐ์„ฑ์ด ํ–ฅ์ƒ๋จ

Story๋ž€ ์ปดํฌ๋„ŒํŠธ์˜ ํŠน์ • ์ƒํƒœ๋ฅผ ์˜๋ฏธํ•˜๋ฉฐ, ๊ฐ ์Šคํ† ๋ฆฌ๋Š” ๊ฐœ๋ณ„์ ์œผ๋กœ ๋ฌธ์„œํ™”๋œ๋‹ค.

๊ฐœ์„ ๋œ์ 

  • ๊ธฐ๋ณธ ๋ Œ๋” ํ•จ์ˆ˜๋ฅผ ์ƒ๋žตํ•ด๋„ ๋œ๋‹ค.

    • ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ ์Šคํ† ๋ฆฌ๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๊ณ  ๋ชจ๋“  ์ธ์ž๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.

  • ์Šคํ† ๋ฆฌ ์žฌ์‚ฌ์šฉ์„ฑ์„ ์œ„ํ•ด ์Šคํ”„๋ ˆ๋“œ ๋ฌธ๋ฒ•์„ ์ง€์›

  • ์ธํ„ฐ๋ ‰์…˜์„ ์œ„ํ•œ play ํ•จ์ˆ˜ ์ง€์›

    • ์Šคํ† ๋ฆฌ๊ฐ€ ๋ Œ๋”๋ง ๋œํ›„ ์‹คํ–‰๋˜๋ฉฐ, ํ…Œ์ŠคํŒ… ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์‚ฌ์šฉ์ž ์ƒํ˜ธ์ž‘์šฉ์„ ์ž‘์„ฑํ•œ๋‹ค.

  • ๊ฒฝ๋กœ์— ๋”ฐ๋ฅธ ์Šคํ† ๋ฆฌ ํƒ€์ดํ‹€ ์ž๋™ ์ง€์ •

    • ๋ฃจํŠธ ๊ฒฝ๋กœ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์Šคํ† ๋ฆฌ ํŒŒ์ผ์˜ ์œ„์น˜์— ๋”ฐ๋ผ ์ œ๋ชฉ์„ ์ž๋™์œผ๋กœ ๊ฒฐ์ •์ง“๋Š”๋‹ค.

Example

// default exportํ•  ๊ฐ์ฒด์—์„œ ์Šคํ† ๋ฆฌ๊ฐ€ ์ž‘์„ฑํ•  ์ปดํฌ๋„ŒํŠธ๋ฅผ ์„ ์–ธ
const meta: Meta<typeof Button> = {
  title: 'Button',
  component: Button,
  tags: ['autodocs'],
  parameters: {
    controls: { exclude: ["className", "IconOnly"], expanded: true },
  },
  decorators: [
    Story => (
      <StoryLayout  className="space-y-2">
        <Story />
      </StoryLayout>
    )
  ],
}

export default meta;

type Story = StoryObj<typeof Button>;

// ์Šคํ† ๋ฆฌ๋Š” ๊ฐ์ฒด ํ˜•ํƒœ๋กœ ๊ฐœ๋ณ„์ ์œผ๋กœ export
export const Default: Story = {
  args: {
    variant: "primary",
    size: "md",
    disabled: false,
    label: "Default Button",
    onClick: action('clicked'),
  },
}

export const Icon: Story = {
  args: {
  // ์Šคํ”„๋ ˆ๋“œ ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํ† ๋ฆฌ๊ฐ„ ์ค‘๋ณต๋˜๋Š” ์„ค์ • ์žฌ์‚ฌ์šฉ
    ...Default.args,
    IconOnly: <AiFillGithub />,
    label: '๊นƒํ—ˆ๋ธŒ ๋ฐ”๋กœ๊ฐ€๊ธฐ',
  },
};

Last updated