-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSelect.stories.tsx
139 lines (121 loc) · 2.79 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
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
import React from 'react';
import { type StoryObj, type Meta } from '@storybook/react';
import Select, { type SelectProps } from '../components/Select';
import '@osrd-project/ui-core/dist/theme.css';
type Option = { value: string; label: string };
const options = [
{ value: 'blue', label: 'Blue' },
{ value: 'red', label: 'Red' },
{ value: 'green', label: 'Green' },
] as Option[];
const SelectWrapper = (props: SelectProps<Option>) => <Select {...props} />;
const meta: Meta<typeof SelectWrapper> = {
component: SelectWrapper,
args: {
label: 'Fill colour',
placeholder: 'Choose',
value: options[0],
options,
getOptionLabel: (option: Option) => option.label,
getOptionValue: (option: Option) => option.value,
// eslint-disable-next-line no-console
onChange: (option?: Option) => console.log(option),
small: false,
disabled: false,
readOnly: false,
},
decorators: [
(Story) => (
<div style={{ maxWidth: '20rem' }}>
<Story />
</div>
),
],
title: 'Core/Select',
tags: ['autodocs'],
};
export default meta;
type StoryType = StoryObj<typeof SelectWrapper>;
export const Default: StoryType = {
args: {
id: 'Default',
value: undefined,
},
};
export const LongText: StoryType = {
args: {
id: 'LongText',
value: undefined,
placeholder: 'Very very very very very very long placeholder',
options: [
{ value: 'blue', label: 'Blue' },
{ value: 'long_value', label: 'Very very very very very very long value' },
],
},
};
export const SelectedOption: StoryType = {
args: {
id: 'SelectedOption',
value: options[1],
},
};
export const Hint: StoryType = {
args: {
id: 'Hint',
hint: 'This is not a choice',
},
};
export const RequiredInput: StoryType = {
args: {
id: 'RequiredInput',
required: true,
},
};
export const InformationSelect: StoryType = {
args: {
id: 'InformationSelect',
required: true,
statusWithMessage: {
status: 'info',
message: 'This is a one way choice',
},
},
};
export const WarningSelect: StoryType = {
args: {
id: 'WarningSelect',
required: true,
statusWithMessage: {
status: 'warning',
},
},
};
export const WarningWithMessageSelect: StoryType = {
args: {
id: 'WarningWithMessageSelect',
required: true,
statusWithMessage: {
status: 'warning',
message: 'This is a one way choice',
},
},
};
export const ErrorSelect: StoryType = {
args: {
id: 'ErrorSelect',
required: true,
statusWithMessage: {
status: 'error',
},
},
};
export const ErrorWithMessageSelect: StoryType = {
args: {
id: 'ErrorWithMessageSelect',
required: true,
statusWithMessage: {
status: 'error',
message: 'This is a one way choice',
},
},
};