【发布时间】:2021-07-05 03:42:24
【问题描述】:
我正在使用 Storybook 在 React 和 TypeScript 中构建设计系统库。大多数组件支持使用 style 属性设置自定义样式。我正在尝试使用 Controls 功能在 Storybook 中反映这一点。
考虑以下带有变体并尝试添加样式道具的 Button 故事:
// Button.stories.js
import { Button } from './button';
export default {
component: Button,
title: 'Button',
argTypes: {
variant: {
control: {
type: 'radio',
options: ['primary', 'secondary']
}
},
style: {
control: {
type: 'text'
},
defaultValue: '{marginBottom: 10}'
}
}
};
当样式道具的类型是React.CSSProperties 时,我应该使用什么正确的控件类型?
defaultValue 的正确格式是什么?
【问题讨论】:
标签: reactjs typescript storybook