Skip to content

Commit c017b7c

Browse files
committed
feat: stories optimzie
stories optimize
1 parent 93bd10e commit c017b7c

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

stories/components/2-Collapse.stories.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ const sampleFolderPanel = {
6161
},
6262
};
6363

64-
export const Basic = () => <Collapse data={[editorPanel, sampleFolderPanel]} />;
64+
export const Basic = () => {
65+
return <div>
66+
<h2>简述</h2>
67+
<p>
68+
Collapse
69+
可以折叠/展开的内容区域。
70+
</p>
71+
<h3>使用示例 尝试点击下方面板看看~</h3>
72+
<Collapse data={[editorPanel, sampleFolderPanel]} />;
73+
</div>
74+
}

stories/components/4-Tree.stories.tsx

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import * as React from 'react';
22
import { useState } from 'react';
3-
import Tree from 'mo/components/tree';
3+
import Tree, { ITreeNodeItem, FileTypes, FileType } from 'mo/components/tree';
44
import { storiesOf } from '@storybook/react';
55
import { withKnobs } from '@storybook/addon-knobs';
66
const stories = storiesOf('Tree', module);
77
stories.addDecorator(withKnobs);
88

9+
const folder = FileTypes.FOLDER as FileType;
10+
const file = FileTypes.FILE as FileType;
11+
912
stories.add('Basic Usage', () => {
1013
const data = [
1114
{
1215
id: '1',
13-
title: 'folder',
14-
name: 'folder',
15-
key: 'folder',
16-
type: 'folder',
16+
name: folder,
17+
type: folder,
1718
contextMenu: [
1819
{
1920
id: 'custom',
@@ -26,52 +27,48 @@ stories.add('Basic Usage', () => {
2627
children: [
2728
{
2829
id: '2',
29-
title: 'abccccccccc',
30-
name: 'abccccccccc',
31-
key: 'abccccccccc',
32-
type: 'folder',
30+
name: 'abc',
31+
type: folder,
3332
children: [
3433
{
3534
id: '3',
36-
title: 'test.txt',
3735
name: 'test.txt',
38-
key: 'test.txt',
39-
type: 'file',
36+
type: file,
4037
icon: 'symbol-file',
4138
},
4239
],
4340
},
4441
{
4542
id: '6',
46-
title: 'xyz',
4743
name: 'xyz',
48-
key: 'xyz',
49-
type: 'folder',
44+
type: folder,
5045
children: [
5146
{
5247
id: '7',
53-
title: 'test.pdf',
5448
name: 'test.pdf',
55-
key: 'test.pdf',
56-
type: 'file',
49+
type: file,
5750
icon: 'file-pdf',
5851
},
5952
],
6053
},
6154
{
6255
id: '10',
63-
title: 'file.yaml',
6456
name: 'file.yaml',
65-
key: 'file.yaml',
66-
type: 'file',
57+
type: file,
6758
},
6859
],
6960
},
7061
];
7162

72-
const [treeData, setTreeData] = useState<any>(data);
63+
const [treeData, setTreeData] = useState<ITreeNodeItem[]>(data);
7364
return (
7465
<div>
66+
<h2>简述</h2>
67+
<p>
68+
Tree
69+
多层次的结构列表。实现组件拖拽、右键面板等简单功能
70+
</p>
71+
<h3>使用示例 尝试点击面板或者右键看看~</h3>
7572
<Tree prefixCls="rc-tree" data={treeData} />
7673
</div>
7774
);

0 commit comments

Comments
 (0)