Skip to content

Latest commit

ย 

History

History
62 lines (44 loc) ยท 1.98 KB

README.md

File metadata and controls

62 lines (44 loc) ยท 1.98 KB

Storybook

์‚ฌ์šฉ๋ชฉ์ 

  • ์ปดํฌ๋„ŒํŠธ์˜ state ๋ณ„ ๋ Œ๋”๋ง ๊ฒฐ๊ณผ๋ฅผ ํ…Œ์ŠคํŠธ
  • ์„œ๋ฒ„๋‚˜ ์•ฑ ์ „์ฒด๋ฅผ ์‹คํ–‰ํ•˜์ง€ ์•Š๊ณ  ์ปดํฌ๋„ŒํŠธ ์ œ์ž‘
  • ๊ฐœ๋ฐœํ•˜๋Š” ๋™์•ˆ ์ปดํฌ๋„ŒํŠธ์˜ UI๊ฐ€ ๋ง๊ฐ€์ง€์ง€ ์•Š๋Š”์ง€ ํ™•์ธ ๊ฐ€๋Šฅ

์‹œ์ž‘ํ•˜๊ธฐ

๊ตฌํ˜„ ์ˆœ์„œ(๊ณต์‹ ํŠœํ† ๋ฆฌ์–ผ์— ๋”ฐ๋ฆ„)

  1. ๊ตฌํ˜„ํ•  ์ปดํฌ๋„ŒํŠธ์—์„œ ํ…Œ์ŠคํŠธ์— ํ•„์š”ํ•œ ์ƒํƒœ ์ •๋ฆฌ(์š”๊ตฌ์‚ฌํ•ญ ๋„์ถœ)
  2. ์ปดํฌ๋„ŒํŠธ ๊ตฌํ˜„
  3. ์Šคํ† ๋ฆฌ ํŒŒ์ผ ์„ค์ •
  4. ๊ตฌํ˜„๋œ UI ํ™•์ธ

export default

export default {
  component: TestComponent,
  title: "TestComponent",
  argTypes: { onClick: { action: "clicked" } },
  decorators: [(story) => <div style={{ padding: "3rem" }}>{story()}</div>],
};
  • component : ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ
  • title : Storybook ์•ฑ์˜ ์‚ฌ์ด๋“œ๋ฐ”์—์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ฐธ์กฐํ•˜๋Š” ๋ฐฉ๋ฒ•
  • excludeStories : Storybook์—์„œ ์Šคํ† ๋ฆฌ๋ฅผ ๋‚ด๋ณด๋‚ผ ๋•Œ ๋ Œ๋”๋ง์—์„œ ์ œ์™ธํ•˜๋Š” ๊ฒƒ
  • argTypes : ๊ฐ๊ฐ์˜ ์Šคํ† ๋ฆฌ์—์„œ ์ธ์ˆ˜(args)์˜ ํ–‰๋™ ๋ฐฉ์‹์„ ๋ช…์‹œ
  • parameters
  • decorators : ์Šคํ† ๋ฆฌ์— ์ž„์˜์˜ wrapper๋ฅผ ์ œ๊ณต

Template.bind()

const Template = (args) => <TestComponent {...args} />;

export const Default = Template.bind({});
Default.args = {
  id: 1,
  title: "Test Component!",
};
  • ํ•จ์ˆ˜๋ฅผ ๋ณต์‚ฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ
  • bind()๋ฅผ ํ†ตํ•ด ํ•จ์ˆ˜๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ ๊ฐ ์Šคํ† ๋ฆฌ๊ฐ€ ๊ณ ์œ ํ•œ ์†์„ฑ์„ ๊ฐ€์ง€๋ฉด์„œ ๋™์ผํ•œ ๊ตฌํ˜„์„ ์‚ฌ์šฉํ•˜๋„๋ก ๋งŒ๋“ฆ

ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ

์ฐธ๊ณ 


[TOP] | [HOME]