storybook-addon-figma,扩展了亮色和暗色主题
快速开始
安装插件
npm i --save-dev @ecomponent/storybook-addon-figma-extended
注册插件
// in .storybook/addons.js
import '@storybook/addon-actions/register'
// register the Figma addon
import '@ecomponent/storybook-addon-figma-extended/register'
将 Figma 设计链接到你的 Story
import React from 'react'
import { storiesOf } from '@storybook/react'
import { WithFigma } from 'storybook-addon-figma'
storiesOf('Button')
.addDecorator(figmaLightDecorator({
urllight: 'https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FLtDkaiW5hZhZhZbKEkPyZ9Pk%2FTesting-1%3Fnode-id%3D425%253A552',
allowFullScreen: true
}))
.addDecorator(figmaDarkDecorator({
urldark: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File',
allowFullScreen: true
}))
.add('With Figma', () => (
<button>My Button</button>
))
在右侧面板中显示 Figma 设计
如果您发现底部的 Figma 面板不够大以容纳您的设计,可以将其移动到窗口右侧,在那里可以提供更多空间。这需要 @storybook/addons-options 插件。但请注意,这只能一次性对**所有** Story 执行,并将所有插件面板移动到右侧。此处显示了一个简单的设置。
安装插件
npm install --save-dev @storybook/addon-options
在您的 addons.js
中注册 options 插件
// in .storybook/addons.js
import '@storybook/addon-actions/register'
import '@ecomponent/storybook-addon-figma-extended/register'
// register the options addon
import '@storybook/addon-options/register';
在您的 config.js
文件中导入并使用 setOptions
函数
// in .storybook/config.js
import * as storybook from '@storybook/react';
// import the options function
import { setOptions } from '@storybook/addon-options';
// set option to show panel in right side
setOptions({
downPanelInRight: true,
});
storybook.configure(() => require('./stories'), module);