Storybook
Control
https://storybook.js.org/docs/react/essentials/controls
注意:要加 type,讓 storybook 知道顯示哪種 input
argTypes: {
propertyA: {
control: {
type: 'select',
options: [
'Item One',
'Item Two',
'Item Three'
],
},
},
},
Data Type | Control Type | Description | Options |
---|---|---|---|
array | array | serialize array into a comma-separated string inside a textbox | separator |
boolean | boolean | checkbox input | - |
number | number | a numeric text box input | min, max, step |
range | a range slider input | min, max, step | |
object | object | json editor text input | - |
enum | radio | radio buttons input | options |
inline-radio | inline radio buttons input | options | |
check | multi-select checkbox input | options | |
inline-check | multi-select inline checkbox input | options | |
select | select dropdown input | options | |
multi-select | multi-select dropdown input | options | |
string | text | simple text input | - |
color | color picker input that assumes strings are color values | - | |
date | date picker input | - |
Parameters
放一些 storybook 提供的選項,可以放在 global 也可以放在個別的 story
https://storybook.js.org/docs/react/writing-stories/parameters
parameters: {
controls: {
disable: true,
},
},
Decorators
可以設定 components 周遭的 ui 環境
https://storybook.js.org/docs/react/writing-stories/decorators