用于 Abstract 集成的 Storybook 插件
一个 Storybook 插件,允许你在 Storybook 面板中链接到 Abstract 图层和集合!
示例
- Storybook:https://storybook-addons-abstract.now.sh/
- 源代码:https://github.com/amccloud/storybook-addons-abstract/tree/master/examples
安装
npm install storybook-addons-abstract
使用
在 main.js
中
module.exports = {
stories: ['../src/**/*.stories.@(tsx|mdx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-create-react-app',
+ 'storybook-addons-abstract/register'
]
};
或使用旧的 addons.js
import "storybook-addons-abstract/register";
使用新的 组件故事格式 API
import React from "react";
import { BlogIndex, BlogGallery, BlogPost } from "../";
export default {
parameters: {
abstract: {
// Copy a collection or layer share url from Abstract
url: "https://share.goabstract.com/733ca894-a4bb-43e3-a2b1-dd27ff6d00c4"
}
}
};
// Name your stories after layers in the collection
export const blogIndex = () => (
<BlogIndex />
);
export const blogGallery = () => (
<BlogGallery />
);
export const blogPost = () => (
<BlogPost />
);
或使用旧的故事
import React from "react";
import { storiesOf } from "@storybook/react";
storiesOf("Blog", module)
.addParameters({
abstract: {
// Copy a collection or layer share url from Abstract
url: "https://share.goabstract.com/733ca894-a4bb-43e3-a2b1-dd27ff6d00c4"
}
})
// Name your stories after layers in the collection
.add("Blog Index", () => <BlogIndex />)
.add("Blog Gallery", () => <BlogGallery />)
.add("Blog Post", () => <BlogPost />);
选项
选项 | 值 | 默认值 | 描述 |
---|---|---|---|
主题 |
"light" | "dark" | "system" |
"light" |
控制嵌入的显示 |
无边框 |
布尔值 |
false |
隐藏嵌入界面,仅显示预览,直到鼠标悬停 |
更改嵌入背景颜色
{
abstract: {
url: "https://share.goabstract.com/733ca894-a4bb-43e3-a2b1-dd27ff6d00c4",
options: {
theme: "dark"
}
}
}
隐藏嵌入界面
{
abstract: {
url: "https://share.goabstract.com/733ca894-a4bb-43e3-a2b1-dd27ff6d00c4",
options: {
chromeless: true
}
}
}