-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Dropdown.stories.js
158 lines (150 loc) · 3.37 KB
/
Dropdown.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
152
153
154
155
156
157
158
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { default as Dropdown, DropdownSkeleton } from '../';
import { Layer } from '../../Layer';
export default {
title: 'Components/Dropdown',
component: Dropdown,
subcomponents: {
DropdownSkeleton,
},
argTypes: {
size: {
options: ['sm', 'md', 'lg'],
control: { type: 'select' },
},
},
};
const items = [
{
id: 'option-0',
text: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit.',
},
{
id: 'option-1',
text: 'Option 1',
},
{
id: 'option-2',
text: 'Option 2',
},
{
id: 'option-3',
text: 'Option 3 - a disabled item',
disabled: true,
},
{
id: 'option-4',
text: 'Option 4',
},
{
id: 'option-5',
text: 'Option 5',
},
];
export const Default = (args) => (
<div style={{ width: 400 }}>
<Dropdown
id="default"
titleText="Dropdown label"
helperText="This is some helper text"
label="Dropdown menu options"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
</div>
);
export const Inline = (args) => (
<div style={{ width: 600 }}>
<Dropdown
id="inline"
titleText="Inline dropdown label"
label="Dropdown menu options"
type="inline"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
</div>
);
export const WithLayer = (args) => (
<div style={{ width: 400 }}>
<Dropdown
id="default"
titleText="First Layer"
helperText="This is some helper text"
label="Dropdown menu options"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
<Layer>
<Dropdown
id="default"
titleText="Second Layer"
helperText="This is some helper text"
label="Dropdown menu options"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
<Layer>
<Dropdown
id="default"
titleText="Third Layer"
helperText="This is some helper text"
label="Dropdown menu options"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
</Layer>
</Layer>
</div>
);
export const InlineWithLayer = (args) => (
<div style={{ width: 600 }}>
<Dropdown
id="inline"
titleText="First Layer"
label="Dropdown menu options"
type="inline"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
<Layer>
<Dropdown
id="inline"
titleText="Second Layer"
label="Dropdown menu options"
type="inline"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
<Layer>
<Dropdown
id="inline"
titleText="Third Layer"
label="Dropdown menu options"
type="inline"
items={items}
itemToString={(item) => (item ? item.text : '')}
{...args}
/>
</Layer>
</Layer>
</div>
);
export const Skeleton = (args) => (
<div style={{ width: 300 }}>
<DropdownSkeleton {...args} />
</div>
);