-
Notifications
You must be signed in to change notification settings - Fork 126
/
Input.stories.tsx
764 lines (724 loc) · 26.6 KB
/
Input.stories.tsx
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
// TODO: Rewrite stories and enable rule (in process of functional refactoring).
/* eslint-disable react/no-unstable-nested-components */
import React from 'react';
import SearchIcon from '@skbkontur/react-icons/Search';
import { Story } from '../../../typings/stories';
import { Input, InputSize } from '../Input';
import { Button } from '../../Button';
import { Gapped } from '../../Gapped';
const styles = {
display: 'inline-block',
verticalAlign: 'middle',
minWidth: '90px',
padding: '5px',
};
export default { title: 'Input' };
export const InputsWithDifferentStates: Story = () => (
<div>
<div>
<div style={styles}>Warning</div>
<div id="warning-small-input-wrapper" style={styles}>
<Input size="small" warning />
</div>
<div id="warning-large-input-wrapper" style={styles}>
<Input size="large" warning />
</div>
</div>
<div>
<div style={styles}>Error</div>
<div id="error-small-input-wrapper" style={styles}>
<Input size="small" error />
</div>
<div id="error-large-input-wrapper" style={styles}>
<Input size="large" error />
</div>
</div>
<div>
<div style={styles}>Disabled</div>
<div id="disabled-small-input-wrapper" style={styles}>
<Input size="small" disabled />
</div>
<div id="disabled-large-input-wrapper" style={styles}>
<Input size="large" disabled />
</div>
</div>
<div>
<div style={styles}>
Disabled
<br /> (with text)
</div>
<div id="disabled-text-small-input-wrapper" style={styles}>
<Input size="small" value="Some text" disabled />
</div>
<div id="disabled-text-large-input-wrapper" style={styles}>
<Input size="large" value="Some text" disabled />
</div>
</div>
<div>
<div style={styles}>Placeholder</div>
<div id="placeholder-small-input-wrapper" style={styles}>
<Input size="small" placeholder="Placeholder" />
</div>
<div id="placeholder-large-input-wrapper" style={styles}>
<Input size="large" placeholder="Placeholder" />
</div>
</div>
<div>
<div style={styles}>Password</div>
<div id="password-small-input-wrapper" style={styles}>
<Input size="small" value="password" type="password" />
</div>
<div id="password-large-input-wrapper" style={styles}>
<Input size="large" value="password" type="password" />
</div>
</div>
<div>
<div style={styles}>Borderless</div>
<div id="borderless-small-input-wrapper" style={styles}>
<Input size="small" borderless />
</div>
<div id="borderless-large-input-wrapper" style={styles}>
<Input size="large" borderless />
</div>
</div>
<div>
<div style={styles}>Left icon</div>
<div id="left-icon-small-input-wrapper" style={styles}>
<Input size="small" leftIcon={<SearchIcon />} />
</div>
<div id="left-icon-large-input-wrapper" style={styles}>
<Input size="large" leftIcon={<SearchIcon />} />
</div>
</div>
<div>
<div style={styles}>Right icon</div>
<div id="right-icon-small-input-wrapper" style={styles}>
<Input size="small" rightIcon={<SearchIcon />} />
</div>
<div id="right-icon-large-input-wrapper" style={styles}>
<Input size="large" rightIcon={<SearchIcon />} />
</div>
</div>
<div>
<div style={styles}>Error and Disabled</div>
<div id="error-disabled-small-input-wrapper" style={styles}>
<Input size="small" error disabled value="Error and Disabled" />
</div>
<div id="error-disabled-large-input-wrapper" style={styles}>
<Input size="large" error disabled value="Error and Disabled" />
</div>
</div>
</div>
);
InputsWithDifferentStates.storyName = 'Inputs with different states';
InputsWithDifferentStates.parameters = {
creevey: {
tests: {
async ['Warning small']() {
const element = await this.browser.findElement({ css: '#warning-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Warning small');
},
async ['Warning large']() {
const element = await this.browser.findElement({ css: '#warning-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Warning large');
},
async ['Error small']() {
const element = await this.browser.findElement({ css: '#error-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Error small');
},
async ['Error large']() {
const element = await this.browser.findElement({ css: '#error-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Error large');
},
async ['Disabled small']() {
const element = await this.browser.findElement({ css: '#disabled-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Disabled small');
},
async ['Disabled large']() {
const element = await this.browser.findElement({ css: '#disabled-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Disabled large');
},
async ['Disabled text small']() {
const element = await this.browser.findElement({ css: '#disabled-text-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Disabled text small');
},
async ['Disabled text large']() {
const element = await this.browser.findElement({ css: '#disabled-text-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Disabled text large');
},
async ['Placeholder small']() {
const element = await this.browser.findElement({ css: '#placeholder-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Placeholder small');
},
async ['Placeholder large']() {
const element = await this.browser.findElement({ css: '#placeholder-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Placeholder large');
},
async ['Password small']() {
const element = await this.browser.findElement({ css: '#password-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Password small');
},
async ['Password large']() {
const element = await this.browser.findElement({ css: '#password-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Password large');
},
async ['Borderless small']() {
const element = await this.browser.findElement({ css: '#borderless-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Borderless small');
},
async ['Borderless large']() {
const element = await this.browser.findElement({ css: '#borderless-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Borderless large');
},
async ['Left icon small']() {
const element = await this.browser.findElement({ css: '#left-icon-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Left icon small');
},
async ['Left icon large']() {
const element = await this.browser.findElement({ css: '#left-icon-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Left icon large');
},
async ['Right icon small']() {
const element = await this.browser.findElement({ css: '#right-icon-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Right icon small');
},
async ['Right icon large']() {
const element = await this.browser.findElement({ css: '#right-icon-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Right icon large');
},
async ['Error and Disabled large']() {
const element = await this.browser.findElement({ css: '#error-disabled-large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Error and Disabled large');
},
async ['Error and Disabled small']() {
const element = await this.browser.findElement({ css: '#error-disabled-small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Error and Disabled large');
},
},
},
};
export const InputsWithDifferentSizes: Story = () => (
<div>
<div id="small-input-wrapper" style={styles}>
<Input size="small" />
</div>
<div id="medium-input-wrapper" style={styles}>
<Input size="medium" />
</div>
<div id="large-input-wrapper" style={styles}>
<Input size="large" />
</div>
</div>
);
InputsWithDifferentSizes.storyName = 'Inputs with different sizes';
InputsWithDifferentSizes.parameters = {
creevey: {
tests: {
async ['Plain small']() {
const element = await this.browser.findElement({ css: '#small-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['Focused small']() {
const element = await this.browser.findElement({ css: '#small-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#small-input-wrapper input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('Focused');
},
async ['With typed text small']() {
const element = await this.browser.findElement({ css: '#small-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#small-input-wrapper input' }))
.sendKeys('Test...')
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With typed text');
},
async ['With long typed text small']() {
const element = await this.browser.findElement({ css: '#small-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#small-input-wrapper input' }))
.sendKeys('Test...')
.sendKeys(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
)
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With long typed text');
},
async ['Plain medium']() {
const element = await this.browser.findElement({ css: '#medium-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['Focused medium']() {
const element = await this.browser.findElement({ css: '#medium-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#medium-input-wrapper input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('Focused');
},
async ['With typed text medium']() {
const element = await this.browser.findElement({ css: '#medium-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#medium-input-wrapper input' }))
.sendKeys('Test...')
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With typed text');
},
async ['With long typed text medium']() {
const element = await this.browser.findElement({ css: '#medium-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#medium-input-wrapper input' }))
.sendKeys('Test...')
.sendKeys(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
)
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With long typed text');
},
async ['Plain large']() {
const element = await this.browser.findElement({ css: '#large-input-wrapper' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['Focused large']() {
const element = await this.browser.findElement({ css: '#large-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#large-input-wrapper input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('Focused');
},
async ['With typed text large']() {
const element = await this.browser.findElement({ css: '#large-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#large-input-wrapper input' }))
.sendKeys('Test...')
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With typed text');
},
async ['With long typed text large']() {
const element = await this.browser.findElement({ css: '#large-input-wrapper' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#large-input-wrapper input' }))
.sendKeys('Test...')
.sendKeys(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
)
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('With long typed text');
},
},
},
};
export const PlaceholderAndMask = () => (
<div>
<table style={{ borderSpacing: 10 }}>
<tr>
<td />
<td>width: "auto"</td>
<td>width: 100px</td>
<td>width: 350px</td>
</tr>
<tr>
<td>placeholder</td>
<td>
<Input placeholder="1234567890 1234567890 1234567890" />
</td>
<td>
<Input width={100} placeholder="1234567890 1234567890 1234567890" />
</td>
<td>
<Input width={350} placeholder="1234567890 1234567890 1234567890" />
</td>
</tr>
<tr>
<td> mask</td>
<td>
<Input mask="********** ********** **********" maskChar={'_'} alwaysShowMask />
</td>
<td>
<Input width={100} mask="********** ********** **********" maskChar={'_'} alwaysShowMask />
</td>
<td>
<Input width={350} mask="********** ********** **********" maskChar={'_'} alwaysShowMask />
</td>
</tr>
<tr>
<td>placeholder and mask</td>
<td>
<Input
mask="********** ********** **********"
maskChar={'_'}
alwaysShowMask
placeholder="1234567890 1234567890 1234567890"
/>
</td>
<td>
<Input
width={100}
mask="********** ********** **********"
maskChar={'_'}
alwaysShowMask
placeholder="1234567890 1234567890 1234567890"
/>
</td>
<td>
<Input
width={350}
mask="********** ********** **********"
maskChar={'_'}
alwaysShowMask
placeholder="1234567890 1234567890 1234567890"
/>
</td>
</tr>
</table>
<table style={{ borderSpacing: 10 }}>
<tr>
<td />
<td>focused</td>
<td>blured</td>
</tr>
<tr>
<td>placeholder and mask</td>
<td>
<Input
autoFocus
mask="********** ********** **********"
maskChar={'_'}
placeholder="1234567890 1234567890 1234567890"
/>
</td>
<td>
<Input
mask="********** ********** **********"
maskChar={'_'}
placeholder="1234567890 1234567890 1234567890"
/>
</td>
</tr>
</table>
</div>
);
PlaceholderAndMask.storyName = 'Placeholder and Mask';
export const InputWithPhoneMask: Story = () => (
<Input width="150" mask="+7 999 999-99-99" maskChar={'_'} placeholder="+7" alwaysShowMask />
);
InputWithPhoneMask.storyName = 'Input with phone mask';
InputWithPhoneMask.parameters = {
creevey: {
tests: {
async Plain() {
await this.expect(await this.takeScreenshot()).to.matchImage('Plain');
},
async Focused() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'input' }))
.perform();
await this.expect(await this.takeScreenshot()).to.matchImage('Focused');
},
async Editing() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'input' }))
.sendKeys('9')
.perform();
await this.expect(await this.takeScreenshot()).to.matchImage('Editing');
},
async Blured() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'input' }))
.sendKeys('9')
.perform();
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'body' }))
.perform();
await this.expect(await this.takeScreenshot()).to.matchImage('Blured');
},
},
},
};
export const SelectAllByProp: Story = () => <Input defaultValue="Some value" selectAllOnFocus />;
SelectAllByProp.storyName = 'Select all by prop';
SelectAllByProp.parameters = {
creevey: {
tests: {
async Plain() {
await this.expect(await this.takeScreenshot()).to.matchImage('Plain');
},
async Focused() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'label' }))
.perform();
await this.expect(await this.takeScreenshot()).to.matchImage('Focused');
},
},
},
};
export const SelectAllByButton: Story = () => {
let input: Input | null = null;
const selectAll = () => {
if (input) {
input.selectAll();
}
};
return (
<div>
<div>
<Input ref={(element) => (input = element)} defaultValue="Some value" />
</div>
<Button onClick={selectAll}>Select all</Button>
</div>
);
};
SelectAllByButton.storyName = 'Select all by button';
SelectAllByButton.parameters = {
creevey: {
tests: {
async Plain() {
await this.expect(await this.takeScreenshot()).to.matchImage('Plain');
},
async Selected() {
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'button' }))
.perform();
await this.expect(await this.takeScreenshot()).to.matchImage('Selected');
},
},
},
};
export const InputWithMaxLengthAttr = () => <Input maxLength={3} placeholder="maxLength={3}" />;
InputWithMaxLengthAttr.storyName = 'Input with maxLength attr';
InputWithMaxLengthAttr.parameters = { creevey: { skip: [true] } };
export const ManualBlinking = () => {
class Sample extends React.Component {
private input: Input | null = null;
public render() {
return (
<Gapped>
<Input ref={this.refInput} />
<button onClick={this.handleClick}>Blink!</button>
</Gapped>
);
}
private handleClick = () => {
if (this.input) {
this.input.blink();
}
};
private refInput = (element: Input | null) => {
this.input = element;
};
}
return <Sample />;
};
ManualBlinking.storyName = 'Manual blinking';
ManualBlinking.parameters = { creevey: { skip: [true] } };
export const PrefixAndSuffixSmall: Story = () => <InputWithPrefixSuffix size="small" />;
PrefixAndSuffixSmall.storyName = 'Prefix and suffix small';
PrefixAndSuffixSmall.parameters = {
creevey: {
tests: {
async Plain() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-small' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['First input focused']() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-small' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#inputWithPrefixOrSuffx-small input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('First input focused');
},
},
},
};
export const PrefixAndSuffixMedium: Story = () => <InputWithPrefixSuffix size="medium" />;
PrefixAndSuffixMedium.storyName = 'Prefix and suffix medium';
PrefixAndSuffixMedium.parameters = {
creevey: {
tests: {
async Plain() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-medium' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['First input focused']() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-medium' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#inputWithPrefixOrSuffx-medium input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('First input focused');
},
},
},
};
export const PrefixAndSuffixLarge: Story = () => <InputWithPrefixSuffix size="large" />;
PrefixAndSuffixLarge.storyName = 'Prefix and suffix large';
PrefixAndSuffixLarge.parameters = {
creevey: {
tests: {
async Plain() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-large' });
await this.expect(await element.takeScreenshot()).to.matchImage('Plain');
},
async ['First input focused']() {
const element = await this.browser.findElement({ css: '#inputWithPrefixOrSuffx-large' });
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: '#inputWithPrefixOrSuffx-large input' }))
.perform();
await this.expect(await element.takeScreenshot()).to.matchImage('First input focused');
},
},
},
};
export const TextStylesReset = () => (
<div
style={{
fontWeight: 'bold',
fontStyle: 'italic',
fontVariant: 'small-caps slashed-zero',
fontStretch: 'expanded',
color: 'red',
lineHeight: '50px',
textAlign: 'right',
textShadow: '3px 3px 3px #333',
textTransform: 'uppercase',
letterSpacing: '5px',
}}
>
<Gapped vertical>
<span>Inherited Styles</span>
<Input placeholder="Placeholder" />
<Input defaultValue="Value" />
<Input defaultValue="Disabled" disabled />
<Input mask="a9*MASK" alwaysShowMask />
<Input leftIcon={<SearchIcon />} prefix="Prefix" suffix="suffix" defaultValue="Value" />
</Gapped>
</div>
);
TextStylesReset.storyName = 'text styles reset';
function InputWithPrefixSuffix({ size }: { size: InputSize }) {
return (
<div style={{ padding: 4 }} id={`inputWithPrefixOrSuffx-${size}`}>
<div style={{ margin: '20px 10px 10px', fontSize: '1.5em' }}>Size {size}</div>
<div>
<div style={{ ...styles, width: 100 }}>Prefix</div>
<div style={styles}>
<Input size={size} prefix="Prefix" placeholder="Placeholder" />
</div>
<div style={styles}>
<Input size={size} prefix="Prefix" defaultValue="Value" />
</div>
</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<div style={{ ...styles, width: 100 }}>Suffix</div>
<div style={styles}>
<Input size={size} suffix="suffix" placeholder="Placeholder" />
</div>
<div style={styles}>
<Input size={size} suffix="suffix" defaultValue="Value" />
</div>
</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<div style={{ ...styles, width: 100 }}>Both preffix and suffix</div>
<div style={styles}>
<Input size={size} prefix="Prefix" suffix="suffix" placeholder="Placeholder" />
</div>
<div style={styles}>
<Input size={size} prefix="Prefix" suffix="suffix" defaultValue="Value" />
</div>
</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<div style={{ ...styles, width: 100 }}>Both preffix and suffix with rightIcon</div>
<div style={styles}>
<Input size={size} rightIcon={<SearchIcon />} prefix="Prefix" suffix="suffix" placeholder="Placeholder" />
</div>
<div style={styles}>
<Input size={size} rightIcon={<SearchIcon />} prefix="Prefix" suffix="suffix" defaultValue="Value" />
</div>
</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<div style={{ ...styles, width: 100 }}>Both preffix and suffix with leftIcon</div>
<div style={styles}>
<Input size={size} leftIcon={<SearchIcon />} prefix="Prefix" suffix="suffix" placeholder="Placeholder" />
</div>
<div style={styles}>
<Input size={size} leftIcon={<SearchIcon />} prefix="Prefix" suffix="suffix" defaultValue="Value" />
</div>
</div>
</div>
);
}
export const UncontrolledInputWithPlaceholder: Story = () => {
const [_, setValue] = React.useState<string>();
return <Input placeholder="Placeholder" onValueChange={(value) => setValue(value)} />;
};
UncontrolledInputWithPlaceholder.storyName = 'Uncontrolled Input With Placeholder';
UncontrolledInputWithPlaceholder.parameters = {
creevey: {
tests: {
async PlainAndTyped() {
const plain = await this.takeScreenshot();
await this.browser
.actions({
bridge: true,
})
.click(this.browser.findElement({ css: 'input' }))
.sendKeys('text')
.perform();
const typed = await this.takeScreenshot();
await this.expect({ plain, typed }).to.matchImages();
},
},
},
};