일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 자바스크립트 딥다이브
- middleware pattern
- 블로그 서비스 최적화
- 올림픽 통계 서비스 최적화
- 학습내용정리
- 진행기록
- js pattern
- Babel과 Webpack
- 스코프
- 이미지 갤러리 최적화
- 커리어
- 모던 자바스크립트 Deep Dive
- 제너레이터와 async/await
- 딥다이브
- unique identifiers
- DOM
- package management
- 브라우저의 렌더링 과정
- const
- 이벤트
- 프론트엔드 성능 최적화 가이드
- mixin pattern
- pr review
- js pattern
- 자바스크립트
- 새 코드 받아오기
- 프로그래머스
- 자바스크립트 패턴
- peerdependencies
- version management
- Today
- Total
Dev Blog
Storybook addons 본문
Essential addons
There are many third-party addons as well as “official” addons developed by the Storybook core team.
- Docs
- Controls
- Actions
- Viewport
- Backgrounds
- Toolbars & globals
- Measure
- Outline
Docs
Storybook gives you tools to expand this basic documentation with prose and layout that feature your components and stories prominently.
Document component usage and properties in Markdown
npm install @storybook/addon-docs
1. DocsPage
Every story gets a DocsPage. DocsPage pulls information from your stories, components, source code, and story metadata to construct a sensible, zero-config default.
2. MDX
MDX is a syntax for writing long-form documentation and stories side-by-side in the same file.
MDX gives you full control over your component documentation.
import { Meta, Story, Canvas } from '@storybook/addon-docs';
import { Checkbox } from './Checkbox';
<Meta title="MDX/Checkbox" component={Checkbox} />
# Checkbox
With `MDX` we can define a story for `Checkbox` right in the middle of our
markdown documentation.
<Canvas>
<Story name="all checkboxes">
<form>
<Checkbox id="Unchecked" label="Unchecked" />
<Checkbox id="Checked" label="Checked" checked />
<Checkbox appearance="secondary" id="second" label="Secondary" checked />
</form>
</Story>
</Canvas>
Controls
Storybook Controls gives you a graphical UI to interact with a component's arguments dynamically.
To use the Controls addon, you need to write your stories using args. Storybook will automatically generate UI controls based on your args and what it can infer about your component
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx
export default {
title: 'Button',
component: Button,
argTypes: {
variant: {
options: ['primary', 'secondary'],
control: { type: 'radio' }
}
}
};
Control Types
Actions
Actions work via supplying special Storybook-generated “action” arguments (referred to as "args" for short) to your stories. There are two ways to get an action arg:
Action argType annotation
You can use argTypes to tell Storybook that an arg to your story should be an action. Usually it makes sense to do this at the component level (although it can be done per story):
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx
export default {
title: 'Button',
argTypes: { onClick: { action: 'clicked' } },
};
Action event handlers
'Development Notes > UI Design System' 카테고리의 다른 글
Design System Research (0) | 2022.11.21 |
---|---|
Why use Storybook (0) | 2021.09.08 |
Get Started (0) | 2021.09.06 |
How to use story book (0) | 2021.05.06 |