-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathpicker.stories.ts
792 lines (766 loc) · 26.4 KB
/
picker.stories.ts
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
/*
Copyright 2020 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { html, TemplateResult } from '@spectrum-web-components/base';
import '@spectrum-web-components/button/sp-button.js';
import '@spectrum-web-components/field-label/sp-field-label.js';
import '@spectrum-web-components/icon/sp-icon.js';
import '@spectrum-web-components/icons-workflow/icons/sp-icon-copy.js';
import '@spectrum-web-components/icons-workflow/icons/sp-icon-delete.js';
import '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';
import '@spectrum-web-components/link/sp-link.js';
import '@spectrum-web-components/menu/sp-menu-item.js';
import '@spectrum-web-components/picker/sp-picker.js';
import '@spectrum-web-components/tooltip/sp-tooltip.js';
import { ifDefined } from 'lit-html/directives/if-defined.js';
import { spreadProps } from '../../../test/lit-helpers.js';
import '../../overlay/stories/index.js';
import { areIconsPresent, isOverlayOpen } from '../../overlay/stories/index.js';
import { argTypes } from './args.js';
import { states } from './states.js';
import { handleChange, StoryArgs, Template } from './template.js';
export default {
title: 'Picker',
component: 'sp-picker',
args: {
disabled: false,
invalid: false,
open: false,
quiet: false,
pending: false,
},
argTypes: {
...argTypes,
onChange: { action: 'change' },
open: {
name: 'open',
type: { name: 'boolean', required: false },
description: 'Whether the menu is open or not.',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
},
control: 'boolean',
},
pending: {
name: 'pending',
type: { name: 'boolean', required: false },
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
},
control: {
type: 'boolean',
},
},
},
};
export const Default = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-1" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-1"
@change=${handleChange(args)}
label="Select a Country with a very long label, too long, in fact"
${spreadProps(args)}
>
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
<sp-menu-item value="option-3">Feather...</sp-menu-item>
<sp-menu-item value="option-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="option-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="option-6">
Make Work Path
</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
export const forcePopoverOnMobile = (args: StoryArgs): TemplateResult => {
return html`
<div style="padding: 40px">
<h1>Force Popover on Mobile</h1>
<p>
The force-popover attribute overrides the mobile device
functionality of rendering a tray so that a popover will always
render no matter the device.
</p>
<ol>
<li>Open Chrome DevTools (or equivalent).</li>
<li>Toggle the Device Toolbar (the phone/tablet icon).</li>
<li>Select a device preset (e.g. iPhone 12).</li>
<li>
Chrome will set user-agent strings, simulate touch, and
adjust DPI.
</li>
<li>Reload the page</li>
<li>Click the Picker 1 and see a tray</li>
<li>Click the Picker 2 and see a popover</li>
</ol>
<sp-field-label for="picker-1" size=${ifDefined(args.size)}>
Do you want to see a tray menu?
</sp-field-label>
<sp-picker
id="picker-1"
@change=${handleChange(args)}
label="Select an option"
>
<sp-menu-item value="option-1">Yes</sp-menu-item>
<sp-menu-item value="option-2">No</sp-menu-item>
</sp-picker>
<sp-field-label for="picker-2" size=${ifDefined(args.size)}>
Do you want to see a popover menu?
</sp-field-label>
<sp-picker
id="picker-2"
force-popover
@change=${handleChange(args)}
label="Select an option"
>
<sp-menu-item value="option-1">Yes</sp-menu-item>
<sp-menu-item value="option-2">No</sp-menu-item>
</sp-picker>
<div>
<p>
This button should't be clickable if a popover is open over
it.
</p>
<sp-button
@click=${() => console.log('Whoops! I was clicked.')}
>
Shouldn't be clickable
</sp-button>
</div>
</div>
`;
};
export const disabled = (args: StoryArgs): TemplateResult => Template(args);
disabled.args = {
disabled: true,
};
export const invalid = (args: StoryArgs): TemplateResult => Template(args);
invalid.args = {
invalid: true,
};
export const tooltip = (args: StoryArgs): TemplateResult => {
const { open, ...rest } = args;
return html`
<sp-field-label for="picker-1" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-1"
@change=${handleChange(args)}
label="Select a Country with a very long label, too long, in fact"
${spreadProps(rest)}
>
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
<sp-menu-item value="option-3">Feather...</sp-menu-item>
<sp-menu-item value="option-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="option-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="option-6">
Make Work Path
</sp-menu-item>
<sp-tooltip
slot="tooltip"
?open=${open}
self-managed
placement="right"
>
This Picker wants to know where you live.
</sp-tooltip>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
tooltip.args = {
open: true,
};
tooltip.decorators = [isOverlayOpen];
export const leftSideLabel = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label
side-aligned="start"
for="picker-1"
size=${ifDefined(args.size)}
>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-1"
@change=${handleChange(args)}
label="Select a Country with a very long label, too long, in fact"
${spreadProps(args)}
>
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
<sp-menu-item value="option-3">Feather...</sp-menu-item>
<sp-menu-item value="option-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="option-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="option-6">
Make Work Path
</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
export const noVisibleLabel = (args: StoryArgs): TemplateResult => {
return html`
<sp-picker
@change=${handleChange(args)}
label="Where do you live?"
${spreadProps(args)}
>
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
<sp-menu-item value="option-3">Feather...</sp-menu-item>
<sp-menu-item value="option-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="option-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="option-6">
Make Work Path
</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
export const slottedLabel = (args: StoryArgs): TemplateResult => {
return html`
<sp-picker @change=${handleChange(args)} ${spreadProps(args)}>
<span slot="label">Where do you live?</span>
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
<sp-menu-item value="option-3">Feather...</sp-menu-item>
<sp-menu-item value="option-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="option-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="option-6">
Make Work Path
</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
export const quiet = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an item"
>
<sp-menu-item value="1">Item 1</sp-menu-item>
<sp-menu-item value="2">Item 2</sp-menu-item>
<sp-menu-item value="3">Item 3</sp-menu-item>
<sp-menu-item value="4">Item 4</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
quiet.args = {
quiet: true,
};
export const quietSideLabel = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label
side-aligned="start"
for="picker-quiet-sidelabel"
size=${ifDefined(args.size)}
>
Where do you live?
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet-sidelabel"
@change=${handleChange(args)}
label="Pick an item"
>
<sp-menu-item value="1">Item 1</sp-menu-item>
<sp-menu-item value="2">Item 2</sp-menu-item>
<sp-menu-item value="3">Item 3</sp-menu-item>
<sp-menu-item value="4">Item 4</sp-menu-item>
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
quietSideLabel.args = {
quiet: true,
};
export const icons = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Choose an action type...
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an action"
value="1"
>
<sp-menu-item value="1">
<sp-icon-edit slot="icon"></sp-icon-edit>
Edit
</sp-menu-item>
<sp-menu-item value="2">
<sp-icon-copy slot="icon"></sp-icon-copy>
Copy
</sp-menu-item>
<sp-menu-item value="3">
<sp-icon-delete slot="icon"></sp-icon-delete>
Delete
</sp-menu-item>
</sp-picker>
`;
};
export const iconsNone = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Choose an action type...
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an action"
value="1"
icons="none"
>
<sp-menu-item value="1">
<sp-icon-edit slot="icon"></sp-icon-edit>
Edit
</sp-menu-item>
<sp-menu-item value="2">
<sp-icon-copy slot="icon"></sp-icon-copy>
Copy
</sp-menu-item>
<sp-menu-item value="3">
<sp-icon-delete slot="icon"></sp-icon-delete>
Delete
</sp-menu-item>
</sp-picker>
`;
};
iconsNone.args = {
open: true,
};
iconsNone.decorators = [isOverlayOpen];
export const iconValue = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Choose an action type...
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an action"
icons="only"
style="width: 100px"
value="2"
>
<sp-menu-item value="1">
<sp-icon-edit slot="icon"></sp-icon-edit>
Edit
</sp-menu-item>
<sp-menu-item value="2">
<sp-icon-copy slot="icon"></sp-icon-copy>
Copy
</sp-menu-item>
<sp-menu-item value="3">
<sp-icon-delete slot="icon"></sp-icon-delete>
Delete
</sp-menu-item>
</sp-picker>
`;
};
export const iconsOnly = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Choose an action type...
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an action"
style="width: 100px"
value="3"
>
<sp-menu-item value="1">
<sp-icon-edit slot="icon" label="Edit"></sp-icon-edit>
</sp-menu-item>
<sp-menu-item value="2">
<sp-icon-copy slot="icon" label="Copy"></sp-icon-copy>
</sp-menu-item>
<sp-menu-item value="3">
<sp-icon-delete slot="icon" label="Delete"></sp-icon-delete>
</sp-menu-item>
</sp-picker>
`;
};
iconsOnly.args = {
open: true,
};
iconsOnly.decorators = [isOverlayOpen];
export const dynamicIcons = (args: StoryArgs): TemplateResult => {
return html`
<p>
The icon displayed in the picker should match the icon of the
selected menu item, even when the icons are updated dynamically.
</p>
<sp-field-label for="picker-quiet" size=${ifDefined(args.size)}>
Choose an action type...
</sp-field-label>
<sp-picker
${spreadProps(args)}
id="picker-quiet"
@change=${handleChange(args)}
label="Pick an action"
value="2"
>
<sp-menu-item value="1">
<sp-icon
slot="icon"
src="https://loremicon.com/rect/20/20/1/png"
></sp-icon>
Edit
</sp-menu-item>
<sp-menu-item value="2">
<sp-icon
slot="icon"
src="https://loremicon.com/rect/20/20/2/png"
></sp-icon>
Copy
</sp-menu-item>
<sp-menu-item value="3">
<sp-icon
slot="icon"
src="https://loremicon.com/rect/20/20/3/png"
></sp-icon>
Delete
</sp-menu-item>
</sp-picker>
<sp-button
@click=${() => {
const icons = document.querySelectorAll('sp-icon');
const seed = Math.round(Math.random() * 1000);
icons.forEach((icon, index) => {
icon.setAttribute(
'src',
`https://loremicon.com/rect/20/20/${seed + index}/png`
);
});
const picker = document.querySelector('sp-picker');
if (picker) picker.open = true;
}}
>
Change icons
</sp-button>
`;
};
dynamicIcons.args = {
open: true,
};
dynamicIcons.decorators = [areIconsPresent];
export const Open = (args: StoryArgs): TemplateResult => {
return html`
<style>
fieldset {
float: left;
clear: left;
margin-bottom: 15px;
}
</style>
<fieldset class="backdrop-filter-test">
<sp-field-label for="picker-open" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-open"
label="Open picker"
${spreadProps(args)}
@change=${handleChange(args)}
>
<span slot="label">
Select a Country with a very long label, too long, in fact
</span>
<sp-menu-item>Deselect</sp-menu-item>
<sp-menu-item>Select Inverse</sp-menu-item>
<sp-menu-item>Feather...</sp-menu-item>
<sp-menu-item>Select and Mask...</sp-menu-item>
<sp-menu-item>Save Selection</sp-menu-item>
<sp-menu-item disabled>Make Work Path</sp-menu-item>
</sp-picker>
</fieldset>
<fieldset>
<sp-field-label for="picker-closed" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-closed"
label="Picker that displays below the options"
@change=${handleChange(args)}
>
<span slot="label">
Other menu that goes behind the open one
</span>
<sp-menu-item>Not so many options...</sp-menu-item>
</sp-picker>
</fieldset>
`;
};
Open.args = {
open: true,
};
Open.decorators = [isOverlayOpen];
export const OpenShowingEdgeCase = (args: StoryArgs): TemplateResult => {
return html`
<style>
fieldset {
float: left;
clear: left;
margin-bottom: 15px;
}
/* Enforce CSS stacking to test "transition-behavior: allow-discrete" */
/* Breaks the story in non-[popover] supporting browsers */
fieldset:nth-of-type(2) {
position: relative;
z-index: 2;
}
.backdrop-filter-test {
backdrop-filter: saturate(80%);
}
</style>
<p>
In browser that do not support
<code>[popover]</code>
, the following "open"
<code>sp-picker</code>
will display behind both the closed
<code>sp-picker</code>
as well as the
<code>fieldset</code>
that contains it.
</p>
<p>
Learn more about this situation in our
<sp-link
href="https://opensource.adobe.com/spectrum-web-components/components/overlay/#fallback-support"
>
documentation site
</sp-link>
.
</p>
<fieldset class="backdrop-filter-test">
<sp-field-label for="picker-open" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-open"
label="Open picker"
${spreadProps(args)}
@change=${handleChange(args)}
>
<span slot="label">
Select a Country with a very long label, too long, in fact
</span>
<sp-menu-item>Deselect</sp-menu-item>
<sp-menu-item>Select Inverse</sp-menu-item>
<sp-menu-item>Feather...</sp-menu-item>
<sp-menu-item>Select and Mask...</sp-menu-item>
<sp-menu-item>Save Selection</sp-menu-item>
<sp-menu-item disabled>Make Work Path</sp-menu-item>
</sp-picker>
</fieldset>
<fieldset>
<sp-field-label for="picker-closed" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-closed"
label="Picker that displays below the options"
@change=${handleChange(args)}
>
<span slot="label">
Other menu that goes behind the open one
</span>
<sp-menu-item>Not so many options...</sp-menu-item>
</sp-picker>
</fieldset>
`;
};
OpenShowingEdgeCase.args = {
open: true,
};
OpenShowingEdgeCase.decorators = [isOverlayOpen];
OpenShowingEdgeCase.swc_vrt = {
skip: true,
};
OpenShowingEdgeCase.parameters = {
// Disables Chromatic's snapshotting on a global level
chromatic: { disableSnapshot: true },
};
export const initialValue = (args: StoryArgs): TemplateResult => {
return html`
<sp-field-label for="picker-initial" size=${ifDefined(args.size)}>
Where do you live?
</sp-field-label>
<sp-picker
id="picker-initial"
@change=${handleChange(args)}
value="item-2"
${spreadProps(args)}
>
<span slot="label">
Select a Country with a very long label, too long in fact
</span>
<sp-menu-item value="item-1">Deselect</sp-menu-item>
<sp-menu-item value="item-2">Select Inverse</sp-menu-item>
<sp-menu-item value="item-3">Feather...</sp-menu-item>
<sp-menu-item value="item-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="item-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="item-6">Make Work Path</sp-menu-item>
</sp-picker>
`;
};
export const readonly = (args: StoryArgs): TemplateResult => {
return html`
<sp-picker
@change=${handleChange(args)}
readonly
value="item-2"
${spreadProps(args)}
>
<span slot="label">
Select a Country with a very long label, too long in fact
</span>
<sp-menu-item value="item-1">Deselect</sp-menu-item>
<sp-menu-item value="item-2">Select Inverse</sp-menu-item>
<sp-menu-item value="item-3">Feather...</sp-menu-item>
<sp-menu-item value="item-4">Select and Mask...</sp-menu-item>
<sp-menu-item value="item-5">Save Selection</sp-menu-item>
<sp-menu-item disabled value="item-6">Make Work Path</sp-menu-item>
</sp-picker>
`;
};
export const custom = (args: StoryArgs): TemplateResult => {
const initialState = 'lb1-mo';
return html`
<sp-field-label for="picker-state" size=${ifDefined(args.size)}>
What state do you live in?
</sp-field-label>
<sp-picker
style="width: 400px;"
@change=${handleChange(args)}
id="picker-state"
label="Pick a state"
${spreadProps(args)}
value=${initialState}
>
${states.map(
(state) => html`
<sp-menu-item
id=${state.id}
value=${state.id}
?selected=${state.id === initialState}
>
${state.label}
</sp-menu-item>
`
)}
</sp-picker>
<p>This is some text.</p>
<p>This is some text.</p>
<p>
This is a
<a href="#anchor">link</a>
.
</p>
`;
};
custom.args = {
open: true,
};
custom.decorators = [isOverlayOpen];
export const BackgroundClickTest = (): TemplateResult => {
return html`
<div style="display: flex; flex-direction: column;">
<sp-picker size="l">
<sp-menu-item value="option-1">Deselect</sp-menu-item>
<sp-menu-item value="option-2">Select Inverse</sp-menu-item>
</sp-picker>
<div style="position: absolute; bottom: 50px;">
<sp-button
@click=${() => {
alert(
'this button should not receive a click event on menu-item selection'
);
console.log(
'this button should not receive a click event on menu-item selection'
);
}}
size="l"
>
I shall not be clicked
</sp-button>
</div>
</div>
`;
};
BackgroundClickTest.swc_vrt = {
skip: true,
};