Norman's Note 諾曼筆記

Norman's Note 諾曼筆記

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 TypeControl TypeDescriptionOptions
arrayarrayserialize array into a comma-separated string inside a textboxseparator
booleanbooleancheckbox input-
numbernumbera numeric text box inputmin, max, step
rangea range slider inputmin, max, step
objectobjectjson editor text input-
enumradioradio buttons inputoptions
inline-radioinline radio buttons inputoptions
checkmulti-select checkbox inputoptions
inline-checkmulti-select inline checkbox inputoptions
selectselect dropdown inputoptions
multi-selectmulti-select dropdown inputoptions
stringtextsimple text input-
colorcolor picker input that assumes strings are color values-
datedate 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