feat: storybook supports g6 demo

This commit is contained in:
baizn 2019-12-31 12:56:28 +08:00
parent ceba71f5e3
commit c6dc7b1c65
3 changed files with 13 additions and 6 deletions

View File

@ -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;
};

View File

@ -9,7 +9,7 @@ const DefaultShape = () => {
useEffect(() => {
if(!graph) {
graph = new G6.Graph({
container,
container: container.current as string | HTMLElement,
width: 500,
height: 500
})

View File

@ -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
// <DefaultShape />
// ))
.add('with', () => ( // 一个 add 表示添加一个 story
<DefaultShape />
))
.add('with some emoji', () => ( // 这里是另一个 story
<span><span role="img" aria-label="so cool">😀 😎 👍 💯</span></span>
));