From c6dc7b1c65aae1dfac5e2d658d53e6233e5e272f Mon Sep 17 00:00:00 2001
From: baizn <576375879@qq.com>
Date: Tue, 31 Dec 2019 12:56:28 +0800
Subject: [PATCH] feat: storybook supports g6 demo
---
.storybook/webpack.config.js | 9 ++++++++-
stories/Shape/component/default-shape.tsx | 2 +-
stories/Shape/shape.stories.tsx | 8 ++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js
index 1cbe45b36a..e8396340ad 100644
--- a/.storybook/webpack.config.js
+++ b/.storybook/webpack.config.js
@@ -1,5 +1,7 @@
-module.exports = ({ config }) => {
+const resolve = require('path').resolve;
+module.exports = ({ config }) => {
+
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('awesome-typescript-loader'),
@@ -34,5 +36,10 @@ module.exports = ({ config }) => {
config.resolve.extensions.push('.ts', '.tsx', '.js');
+ config.resolve.alias = {
+ '@g6/types': resolve(process.cwd(), './types'),
+ '@g6': resolve(process.cwd(), './src')
+ }
+
return config;
};
diff --git a/stories/Shape/component/default-shape.tsx b/stories/Shape/component/default-shape.tsx
index 02b04895ab..51fff4df1d 100644
--- a/stories/Shape/component/default-shape.tsx
+++ b/stories/Shape/component/default-shape.tsx
@@ -9,7 +9,7 @@ const DefaultShape = () => {
useEffect(() => {
if(!graph) {
graph = new G6.Graph({
- container,
+ container: container.current as string | HTMLElement,
width: 500,
height: 500
})
diff --git a/stories/Shape/shape.stories.tsx b/stories/Shape/shape.stories.tsx
index b5f0470ea8..0e6ac1c063 100644
--- a/stories/Shape/shape.stories.tsx
+++ b/stories/Shape/shape.stories.tsx
@@ -2,15 +2,15 @@
import { storiesOf } from '@storybook/react';
import { Button } from '@storybook/react/demo'; // 这里引入你想展示的组件
import React from 'react';
-// import DefaultShape from './component/default-shape'
+import DefaultShape from './component/default-shape'
export default { title: 'Shape' };
storiesOf('Shape', module)
- // .add('with', () => ( // 一个 add 表示添加一个 story
- //
- // ))
+ .add('with', () => ( // 一个 add 表示添加一个 story
+
+ ))
.add('with some emoji', () => ( // 这里是另一个 story
😀 😎 👍 💯
));
\ No newline at end of file