此包已弃用
此包不再维护,已停止主动开发。
安装
yarn add storybook-addon-emotion-theme --dev
添加到 .storybook/addons.js
import 'storybook-addon-emotion-theme/dist/register';
将 addDecorator 添加到 .storybook/config.js
import { addDecorator } from '@storybook/react';
import { withThemesProvider } from 'storybook-addon-emotion-theme';
const themes = [theme1, theme2];
addDecorator(withThemesProvider(themes));
或
将 addDecorator 添加到故事
import {withThemesProvider} from 'storybook-addon-emotion-theme';
const themes = [theme1, theme2];
storiesOf("demo", module)
.addDecorator(withThemesProvider(themes))
.add("demo div", () => <div>DEMO</div>);
提醒
确保每个主题都具有 name
属性。例如
const myTheme = {
name: "Light",
primaryColor: "blue"
}
这用于在 Storybook UI 中显示。
贡献
yarn
yarn build
yarn example
感谢
感谢 Carlos 创建了 storybook-addon-styled-component-theme,该库在此基础上构建。