This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathselect.stories.tsx
93 lines (85 loc) · 2.22 KB
/
select.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
import React, { useState } from 'react';
import { Story } from '@storybook/react';
import Select, { SelectItem } from './';
import { SelectInputProps } from '@material-ui/core/Select/SelectInput';
const items: Array<SelectItem> = [
{
id: '1',
label: 'DAI',
subLabel: 'stablecoin',
iconUrl: 'https://via.placeholder.com/64x64',
},
{ id: '2', label: 'GNO', iconUrl: 'https://via.placeholder.com/128x128' },
{ id: '3', label: 'BrokenImage', iconUrl: 'https://broken-image.test' },
{ id: '4', label: 'without icon' },
];
export default {
title: 'Inputs/Select',
component: Select,
parameters: {
componentSubtitle: 'Select Input.',
},
decorators: [
(TheStory: any) => (
<div style={{ width: '300px' }}>
<TheStory />
</div>
),
],
};
export const SimpleSelect: Story<SelectInputProps> = (
args
): React.ReactElement => {
const [activeItemId, setActiveItemId] = useState('');
return (
<Select
id="simple-select"
label="Select Token"
name="default-select"
items={items}
activeItemId={activeItemId}
fullWidth
onItemClick={(id) => {
setActiveItemId(id);
}}
fallbackImage={'https://via.placeholder.com/32x32'} // image source or URL
{...args}
/>
);
};
export const ErrorSelect = (): React.ReactElement => {
const [activeItemId, setActiveItemId] = useState('');
return (
<Select
id="error-select"
label="Select Token"
name="default-select"
error="Something went wrong"
helperText="Something went wrong"
items={items}
activeItemId={activeItemId}
onItemClick={(id) => {
setActiveItemId(id);
}}
fallbackImage={'https://via.placeholder.com/32x32'} // image source or URL
/>
);
};
export const DisabledSelect = (): React.ReactElement => {
const [activeItemId, setActiveItemId] = useState('');
return (
<Select
id="error-select"
disabled
label="Select Token"
name="default-select"
fullWidth
items={items}
activeItemId={activeItemId}
onItemClick={(id) => {
setActiveItemId(id);
}}
fallbackImage={'https://via.placeholder.com/32x32'} // image source or URL
/>
);
};