storybook

一、安装与启动
npx -p @storybook/cli sb init

npm run storybook

二、使用
import React from ‘react’
import { storiesOf } from ‘@storybook/react’
import { action } from ‘@storybook/addon-actions’

import Button from ‘./button’

const defaultButton = () => (
<Button onClick={action(‘clicked’)}>default button
)

const buttonWithSize = () => (
<>
large button  
large button
</>
)

const buttonWithType = () => (
<>
primary button  
danger button  
link button  
</>
)

storiesOf(‘Button Component’, module)
.add(‘默认 Button’, defaultButton)
.add(‘不同尺寸的 Button’, buttonWithSize)
.add(‘不同类型的 Button’, buttonWithType)

三、设置展示详细信息
1、安装
yarn add @storybook/addon-info
yarn add @types/storybook__addon-info

2、使用
import { withInfo } from ‘@storybook/addon-info’

storiesOf(‘Button Component’, module)
.addDecorator(withInfo)
.addParameters({
info: {
text: this is a very nice component ## this is a header ~~~js const a = 'hello word!' ~~~,
inline: true
}
})
.add(‘默认 Button’, defaultButton, {info: {inline: false}})
.add(‘不同尺寸的 Button’, buttonWithSize)
.add(‘不同类型的 Button’, buttonWithType)

四、自动化部署
安装依赖
yarn add --dev react-docgen-typescript-loader

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值