Skip to content

Commit bfb1231

Browse files
Update select examples
1 parent fb090fa commit bfb1231

File tree

1 file changed

+25
-50
lines changed

1 file changed

+25
-50
lines changed
Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,58 @@
11
import { type Meta, type StoryObj } from '@storybook/react-vite';
2-
import { useState } from 'react';
32

43
import { Select } from '#components/form-elements/select/index.js';
5-
import { TextInput } from '#components/form-elements/text-input/index.js';
64

75
const meta: Meta<typeof Select> = {
86
title: 'Form Elements/Select',
97
component: Select,
108
args: {
11-
label: 'Label text goes here',
12-
labelProps: { isPageHeading: true, size: 'l' },
9+
label: 'Sort by',
10+
labelProps: { isPageHeading: true },
1311
},
12+
render: (args) => (
13+
<Select {...args}>
14+
<Select.Option>Choose location</Select.Option>
15+
<Select.Option value="eastmidlands">East Midlands</Select.Option>
16+
<Select.Option value="eastofengland">East of England</Select.Option>
17+
<Select.Option value="london">London</Select.Option>
18+
<Select.Option value="northeast">North East</Select.Option>
19+
<Select.Option value="northwest">North West</Select.Option>
20+
<Select.Option value="southeast">South East</Select.Option>
21+
<Select.Option value="southwest">South West</Select.Option>
22+
<Select.Option value="westmidlands">West Midlands</Select.Option>
23+
<Select.Option value="yorkshire">Yorkshire and the Humber</Select.Option>
24+
</Select>
25+
),
1426
};
1527
export default meta;
1628
type Story = StoryObj<typeof Select>;
1729

1830
export const Standard: Story = {
19-
args: {
20-
defaultValue: '2',
21-
},
2231
render: (args) => (
2332
<Select {...args}>
24-
<Select.Option value="1">NHS.UK frontend option 1</Select.Option>
25-
<Select.Option value="2">NHS.UK frontend option 2</Select.Option>
26-
<Select.Option value="3" disabled>
27-
NHS.UK frontend option 3
28-
</Select.Option>
33+
<Select.Option value="published">Recently published</Select.Option>
34+
<Select.Option value="updated">Recently updated</Select.Option>
35+
<Select.Option value="views">Most view</Select.Option>
36+
<Select.Option value="comments">Most comments</Select.Option>
2937
</Select>
3038
),
3139
};
3240

3341
export const SelectWithHintText: Story = {
3442
args: {
35-
hint: 'Hint text goes here',
43+
hint: 'This can be different to where you went before',
3644
},
37-
render: (args) => (
38-
<Select {...args}>
39-
<Select.Option value="1">NHS.UK frontend option 1</Select.Option>
40-
<Select.Option value="2">NHS.UK frontend option 2</Select.Option>
41-
<Select.Option value="3">NHS.UK frontend option 3</Select.Option>
42-
</Select>
43-
),
4445
};
4546

4647
export const SelectWithError: Story = {
47-
render: function SelectWithErrorRender(args) {
48-
const [error, setError] = useState<string>('Error message goes here');
49-
return (
50-
<>
51-
<Select error={error} {...args}>
52-
<Select.Option value="1">NHS.UK frontend option 1</Select.Option>
53-
<Select.Option value="2">NHS.UK frontend option 2</Select.Option>
54-
<Select.Option value="3">NHS.UK frontend option 3</Select.Option>
55-
</Select>
56-
<TextInput onChange={(e) => setError(e.currentTarget.value)} value={error} />
57-
</>
58-
);
48+
args: {
49+
error: 'Select a location',
5950
},
60-
61-
name: 'Select With Error (String)',
6251
};
6352

6453
export const SelectWithErrorAndHintText: Story = {
6554
args: {
66-
hint: 'Hint text goes here',
67-
},
68-
render: function SelectWithErrorAndHintTextRender(args) {
69-
const [error, setError] = useState<string>('Error message goes here');
70-
return (
71-
<>
72-
<Select error={error} {...args}>
73-
<Select.Option value="1">NHS.UK frontend option 1</Select.Option>
74-
<Select.Option value="2">NHS.UK frontend option 2</Select.Option>
75-
<Select.Option value="3">NHS.UK frontend option 3</Select.Option>
76-
</Select>
77-
<TextInput onChange={(e) => setError(e.currentTarget.value)} value={error} />
78-
</>
79-
);
55+
hint: 'This can be different to where you went before',
56+
error: 'Select a location',
8057
},
81-
82-
name: 'Select With Error and Hint (String)',
8358
};

0 commit comments

Comments
 (0)