-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
addon-docs-blocks.stories.js
151 lines (135 loc) · 3.25 KB
/
addon-docs-blocks.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React from 'react';
import {
Title,
Subtitle,
Description,
Primary,
ArgsTable,
Stories,
} from '@storybook/addon-docs/blocks';
import { DocgenButton } from '../../components/DocgenButton';
import BaseButton from '../../components/BaseButton';
import { ButtonGroup, SubGroup } from '../../components/ButtonGroup';
export default {
title: 'Addons/Docs/stories docs blocks',
component: DocgenButton,
parameters: {
docs: {
page: () => (
<>
<Title />
<Subtitle />
<Description />
<Primary />
<ArgsTable />
<Stories />
</>
),
},
},
};
export const defDocsPage = () => <div>Default docs page</div>;
export const smallDocsPage = () => <div>Just primary story, </div>;
smallDocsPage.parameters = {
docs: {
page: () => (
<>
<Title />
<Primary />
</>
),
},
};
export const checkBoxProps = () => <div>Primary props displayed with a check box </div>;
checkBoxProps.parameters = {
docs: {
page: () => {
const [showProps, setShowProps] = React.useState(false);
return (
<>
<Title />
<Subtitle />
<Description />
<Primary />
<label>
<input type="checkbox" checked={showProps} onChange={() => setShowProps(!showProps)} />
<span>display props</span>
</label>
{showProps && <ArgsTable />}
</>
);
},
},
};
export const customLabels = () => <div>Display custom title, Subtitle, Description</div>;
customLabels.parameters = {
docs: {
page: () => (
<>
<Title>Custom title</Title>
<Subtitle>Custom sub title</Subtitle>
<Description>Custom description</Description>
<Primary />
<ArgsTable />
<Stories title="Custom stories title" />
</>
),
},
};
export const customStoriesFilter = () => <div>Displays ALL stories (not excluding first one)</div>;
customStoriesFilter.parameters = {
docs: {
page: () => <Stories includePrimary />,
},
};
export const multipleComponents = () => (
<ButtonGroup>
<DocgenButton label="one" />
<DocgenButton label="two" />
<DocgenButton label="three" />
</ButtonGroup>
);
multipleComponents.storyName = 'Many Components';
multipleComponents.parameters = {
component: ButtonGroup,
subcomponents: {
SubGroup,
'Docgen Button': DocgenButton,
'Base Button': BaseButton,
},
docs: {
page: () => (
<>
<Title />
<Subtitle />
<Description />
<Primary name="Many Components" />
<ArgsTable />
</>
),
},
};
export const componentsProps = () => <div>Display multiple prop tables in tabs</div>;
componentsProps.subcomponents = {
'Docgen Button': DocgenButton,
'Base Button': BaseButton,
};
componentsProps.parameters = {
docs: {
page: () => (
<>
<Title>Multiple prop tables</Title>
<Description>
Here's what happens when your component has some related components
</Description>
<ArgsTable
components={{
'ButtonGroup Custom': ButtonGroup,
'Docgen Button': DocgenButton,
'Base Button': BaseButton,
}}
/>
</>
),
},
};