-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathfluid-dropdown.stories.ts
More file actions
270 lines (258 loc) · 7.02 KB
/
Copy pathfluid-dropdown.stories.ts
File metadata and controls
270 lines (258 loc) · 7.02 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/**
* Copyright IBM Corp. 2025
*
* 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 { html } from 'lit';
import { ifDefined } from 'lit/directives/if-defined.js';
import './index';
import View16 from '@carbon/icons/es/view/16.js';
import FolderOpen16 from '@carbon/icons/es/folder--open/16.js';
import Folders16 from '@carbon/icons/es/folders/16.js';
import '../dropdown/dropdown-item';
import '../ai-label';
import '../icon-button';
import { iconLoader } from '../../globals/internal/icon-loader';
import '../toggle-tip/toggletip';
const content = html`
<div slot="body-text">
<p class="secondary">AI Explained</p>
<h2 class="ai-label-heading">84%</h2>
<p class="secondary bold">Confidence score</p>
<p class="secondary">
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
</p>
<hr />
<p class="secondary">Model type</p>
<p class="bold">Foundation model</p>
</div>
`;
const actions = html`
<cds-icon-button kind="ghost" slot="actions" size="lg">
${iconLoader(View16, { slot: 'icon' })}
<span slot="tooltip-content"> View </span>
</cds-icon-button>
<cds-icon-button kind="ghost" slot="actions" size="lg">
${iconLoader(FolderOpen16, { slot: 'icon' })}
<span slot="tooltip-content"> Open folder</span>
</cds-icon-button>
<cds-icon-button kind="ghost" slot="actions" size="lg">
${iconLoader(Folders16, { slot: 'icon' })}
<span slot="tooltip-content"> Folders </span>
</cds-icon-button>
<cds-ai-label-action-button>View details</cds-ai-label-action-button>
`;
const items = [
{
value: 'option-0',
text: 'Lorem, ipsum dolor sit amet consectetur adipisicing elit.',
},
{
value: 'option-1',
text: 'Option 1',
},
{
value: 'option-2',
text: 'Option 2',
},
{
value: 'option-3',
text: 'Option 3 - a disabled item',
disabled: true,
},
{
value: 'option-4',
text: 'Option 4',
},
];
const args = {
defaultWidth: 400,
disabled: false,
helperText: '',
invalid: false,
invalidText:
'Error message that is really long can wrap to more lines but should not be excessively long',
label: 'This is an example label',
readOnly: false,
titleText: 'This is an example title',
warn: false,
warnText:
'Warning message that is really long can wrap to more lines but should not be excessively long.',
};
const argTypes = {
defaultWidth: {
control: { type: 'range', min: 300, max: 800, step: 50 },
},
disabled: {
control: 'boolean',
description: 'Specify whether the control is disabled.',
},
helperText: {
control: 'text',
description:
'Provide helper text that is used alongside the control label for additional help.',
},
invalid: {
control: 'boolean',
description: 'Specify if the currently value is invalid.',
},
invalidText: {
control: 'text',
description: 'Message which is displayed if the value is invalid.',
},
label: {
control: 'text',
description: 'The default content of the trigger button.',
},
readOnly: {
control: 'boolean',
description: 'Whether or not the Dropdown is readonly.',
},
titleText: {
control: 'text',
description:
'Provide the title text that will be read by a screen reader when visiting this control.',
},
warn: {
control: 'boolean',
description: 'Specify whether the control is currently in warning state.',
},
warnText: {
control: 'text',
description:
'Provide the text that is displayed when the control is in warning state.',
},
};
export const Default = {
args,
argTypes,
render: ({
defaultWidth,
disabled,
helperText,
invalid,
invalidText,
label,
readOnly,
titleText,
warn,
warnText,
}) => html`
<div style="width:${defaultWidth}px;">
<cds-fluid-dropdown
?disabled="${disabled}"
helper-text="${ifDefined(helperText)}"
?invalid="${invalid}"
invalid-text="${ifDefined(invalidText)}"
label="${ifDefined(label)}"
?read-only="${readOnly}"
title-text="${ifDefined(titleText)}"
?warn="${warn}"
warn-text="${ifDefined(warnText)}">
${items.map(
(elem) => html`
<cds-dropdown-item ?disabled=${elem.disabled} value="${elem.value}"
>${elem.text}</cds-dropdown-item
>
`
)}
</cds-fluid-dropdown>
</div>
`,
};
export const WithToggletip = {
render: () => {
return html`
<div style="width:400px;">
<cds-fluid-dropdown>
<cds-toggletip autoAlign="true" slot="title-text">
Dropdown label
<p slot="body-text">Additional field information here.</p>
</cds-toggletip>
<cds-dropdown-item
value="An example option that is really long to show what should be done to handle long text"
>An example option that is really long to show what should be done
to handle long text</cds-dropdown-item
>
<cds-dropdown-item value="option-1">Option 1</cds-dropdown-item>
<cds-dropdown-item value="option-2">Option 2</cds-dropdown-item>
<cds-dropdown-item value="option-3">Option 3</cds-dropdown-item>
<cds-dropdown-item value="option-4">Option 4</cds-dropdown-item>
</cds-fluid-dropdown>
</div>
`;
},
};
export const Skeleton = {
parameters: {
percy: {
skip: true,
},
},
args: {
defaultWidth: 400,
},
argTypes: {
defaultWidth: {
control: { type: 'range', min: 300, max: 800, step: 50 },
},
},
render: ({ defaultWidth }) => html`
<div style="width: ${defaultWidth}px;">
<cds-fluid-dropdown-skeleton></cds-fluid-dropdown-skeleton>
</div>
`,
};
export const WithAILabel = {
args,
argTypes: {
...argTypes,
},
render: ({
defaultWidth,
disabled,
helperText,
invalid,
invalidText,
label,
readOnly,
titleText,
warn,
warnText,
}) => {
return html` <div style="width:${defaultWidth}px;">
<cds-fluid-dropdown
?disabled="${disabled}"
helper-text="${ifDefined(helperText)}"
?invalid="${invalid}"
invalid-text="${ifDefined(invalidText)}"
label="${ifDefined(label)}"
?read-only="${readOnly}"
title-text="${ifDefined(titleText)}"
?warn="${warn}"
warn-text="${ifDefined(warnText)}">
<cds-ai-label alignment="bottom-left">
${content}${actions}</cds-ai-label
>
${items.map(
(elem) => html`
<cds-dropdown-item ?disabled=${elem.disabled} value="${elem.value}"
>${elem.text}</cds-dropdown-item
>
`
)}
</cds-fluid-dropdown>
</div>`;
},
};
const meta = {
decorators: [
(story) => {
return html`<div style="width: 400px">${story()}</div>`;
},
],
title: 'Components/Fluid Components/FluidDropdown',
};
export default meta;