Skip to content

Commit 055c5bb

Browse files
Always pass args to storybook examples
1 parent f98d12a commit 055c5bb

22 files changed

+155
-110
lines changed

stories/Content Presentation/DoAndDontList.stories.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ export default meta;
4545
type Story = StoryObj<typeof DoAndDontList>;
4646

4747
export const Do: Story = {
48+
args: {
49+
listType: 'do',
50+
},
4851
render: (args) => (
49-
<DoAndDontList listType="do">
52+
<DoAndDontList {...args}>
5053
<DoAndDontList.Item>
5154
cover blisters that are likely to burst with a soft plaster or dressing
5255
</DoAndDontList.Item>
@@ -59,8 +62,11 @@ export const Do: Story = {
5962
};
6063

6164
export const Dont: Story = {
65+
args: {
66+
listType: 'dont',
67+
},
6268
render: (args) => (
63-
<DoAndDontList listType="dont">
69+
<DoAndDontList {...args}>
6470
<DoAndDontList.Item>burst a blister yourself</DoAndDontList.Item>
6571
<DoAndDontList.Item>peel the skin off a burst blister</DoAndDontList.Item>
6672
<DoAndDontList.Item>pick at the edges of the remaining skin</DoAndDontList.Item>
@@ -90,8 +96,11 @@ export const Dont: Story = {
9096
* | JSX | The JSX will be rendered, such as `<span>` |
9197
*/
9298
export const CustomPrefixText: Story = {
93-
render: () => (
94-
<DoAndDontList listType="dont">
99+
args: {
100+
listType: 'dont',
101+
},
102+
render: (args) => (
103+
<DoAndDontList {...args}>
95104
<DoAndDontList.Item prefixText="You must not">burst a blister yourself</DoAndDontList.Item>
96105
<DoAndDontList.Item prefixText={undefined}>
97106
peel the skin off a burst blister

stories/Content Presentation/NotificationBanner.stories.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type Story = StoryObj<typeof NotificationBanner>;
4141

4242
export const StandardPanel: Story = {
4343
args: {},
44-
render: () => (
45-
<NotificationBanner>
44+
render: (args) => (
45+
<NotificationBanner {...args}>
4646
<NotificationBanner.Heading>
4747
The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025.
4848
</NotificationBanner.Heading>
@@ -51,9 +51,11 @@ export const StandardPanel: Story = {
5151
};
5252

5353
export const SuccessPanel: Story = {
54-
args: {},
55-
render: () => (
56-
<NotificationBanner success>
54+
args: {
55+
success: true,
56+
},
57+
render: (args) => (
58+
<NotificationBanner {...args}>
5759
<NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading>
5860
<p>
5961
Contact{' '}
@@ -66,8 +68,8 @@ export const SuccessPanel: Story = {
6668

6769
export const StandardPanelWithLink: Story = {
6870
args: {},
69-
render: () => (
70-
<NotificationBanner>
71+
render: (args) => (
72+
<NotificationBanner {...args}>
7173
<NotificationBanner.Heading>
7274
You have 7 days left to send your application.{' '}
7375
<NotificationBanner.Link href="#">View application</NotificationBanner.Link>.
@@ -80,8 +82,8 @@ export const StandardPanelWithCustomTitle: Story = {
8082
args: {
8183
title: 'Important Message',
8284
},
83-
render: () => (
84-
<NotificationBanner>
85+
render: (args) => (
86+
<NotificationBanner {...args}>
8587
<NotificationBanner.Heading>Upcoming maintenance</NotificationBanner.Heading>
8688
<p>The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025.</p>
8789
</NotificationBanner>
@@ -90,8 +92,8 @@ export const StandardPanelWithCustomTitle: Story = {
9092

9193
export const StandardPanelWithCustomTitleElement: Story = {
9294
args: {},
93-
render: () => (
94-
<NotificationBanner>
95+
render: (args) => (
96+
<NotificationBanner {...args}>
9597
<NotificationBanner.Title>
9698
Maintenance <time dateTime="2025-01-01">January 1</time>
9799
</NotificationBanner.Title>
@@ -103,8 +105,8 @@ export const StandardPanelWithCustomTitleElement: Story = {
103105

104106
export const StandardPanelWithList: Story = {
105107
args: {},
106-
render: () => (
107-
<NotificationBanner>
108+
render: (args) => (
109+
<NotificationBanner {...args}>
108110
<NotificationBanner.Heading>4 files uploaded</NotificationBanner.Heading>
109111
<ul>
110112
<li>
@@ -126,8 +128,8 @@ export const StandardPanelWithList: Story = {
126128

127129
export const StandardPanelWithLotsOfContent: Story = {
128130
args: {},
129-
render: () => (
130-
<NotificationBanner>
131+
render: (args) => (
132+
<NotificationBanner {...args}>
131133
<NotificationBanner.Heading>
132134
Check if you need to apply the reverse charge to this application
133135
</NotificationBanner.Heading>

stories/Content Presentation/Panel.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ export default meta;
99
type Story = StoryObj<typeof Panel>;
1010

1111
export const StandardPanel: Story = {
12-
render: () => (
13-
<Panel>
12+
render: (args) => (
13+
<Panel {...args}>
1414
<Panel.Title>Booking complete</Panel.Title>
1515
We have sent you a confirmation email
1616
</Panel>
1717
),
1818
};
1919

2020
export const PanelWithCustomHeadingLevel: Story = {
21-
render: () => (
22-
<Panel>
21+
render: (args) => (
22+
<Panel {...args}>
2323
<Panel.Title headingLevel="h2">Booking complete</Panel.Title>
2424
We have sent you a confirmation email
2525
</Panel>

stories/Content Presentation/Tabs.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export default meta;
1818
type Story = StoryObj<typeof Tabs>;
1919

2020
export const Standard: Story = {
21-
render: () => (
22-
<Tabs>
21+
render: (args) => (
22+
<Tabs {...args}>
2323
<Tabs.Title>Contents</Tabs.Title>
2424
<Tabs.List>
2525
<Tabs.ListItem id="past-day">Past day</Tabs.ListItem>
@@ -48,8 +48,8 @@ export const Standard: Story = {
4848
* It also displays if the user has JavaScript disabled.
4949
*/
5050
export const DifferentAccessibleHeading: Story = {
51-
render: () => (
52-
<Tabs>
51+
render: (args) => (
52+
<Tabs {...args}>
5353
<Tabs.Title headingLevel="h1">Tabs title</Tabs.Title>
5454
<Tabs.List>
5555
<Tabs.ListItem id="past-day-2">Past day</Tabs.ListItem>

stories/Content Presentation/Tag.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Story = StoryObj<typeof Tag>;
1111
export const StandardTag: Story = { args: { children: 'Standard' } };
1212

1313
export const AllColours: Story = {
14-
render: (args) => (
14+
render: () => (
1515
<div className="tag-wrapper">
1616
<Tag modifier="white">Started</Tag>
1717
<Tag modifier="grey">Not started</Tag>

stories/Content Presentation/WarningCallout.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Story = StoryObj<typeof WarningCallout>;
1010

1111
export const StandardWarningCallout: Story = {
1212
render: (args) => (
13-
<WarningCallout>
13+
<WarningCallout {...args}>
1414
<WarningCallout.Heading>Important</WarningCallout.Heading>
1515
<p>
1616
For safety, tell your doctor or pharmacist if you&apos;re taking any other medicines,
@@ -24,7 +24,7 @@ export const StandardWarningCallout: Story = {
2424

2525
export const WarningCalloutWithCustomHeading: Story = {
2626
render: (args) => (
27-
<WarningCallout>
27+
<WarningCallout {...args}>
2828
<WarningCallout.Heading>School, nursery or work</WarningCallout.Heading>
2929
<p>
3030
Stay away from school, nursery or work until all the spots have crusted over. This is
@@ -36,7 +36,7 @@ export const WarningCalloutWithCustomHeading: Story = {
3636

3737
export const WarningCalloutWithCustomHeadingLevel: Story = {
3838
render: (args) => (
39-
<WarningCallout>
39+
<WarningCallout {...args}>
4040
<WarningCallout.Heading headingLevel="h4">School, nursery or work</WarningCallout.Heading>
4141
<p>
4242
Stay away from school, nursery or work until all the spots have crusted over. This is

stories/Form Elements/CharacterCount.stories.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ export default meta;
1818
type Story = StoryObj<typeof CharacterCount>;
1919

2020
export const Standard: Story = {
21-
render: () => (
21+
render: (args) => (
2222
<CharacterCount
2323
label="Can you provide more detail?"
2424
labelProps={{ isPageHeading: true, size: 'l' }}
2525
hint="Do not include personal information like your name, date of birth or NHS number"
2626
name="example"
2727
maxLength={200}
2828
rows={5}
29+
{...args}
2930
/>
3031
),
3132
};
@@ -36,14 +37,15 @@ export const Standard: Story = {
3637
* Use the `countType` prop to vary this behaviour.
3738
*/
3839
export const WordCountLimit: Story = {
39-
render: () => (
40+
render: (args) => (
4041
<CharacterCount
4142
label="Can you provide more detail?"
4243
labelProps={{ isPageHeading: true, size: 'l' }}
4344
hint="Do not include personal information like your name, date of birth or NHS number"
4445
name="example"
4546
maxWords={150}
4647
rows={5}
48+
{...args}
4749
/>
4850
),
4951
};
@@ -54,7 +56,7 @@ export const WordCountLimit: Story = {
5456
* Use the `threshold` prop to only show the count message when users have reached that percentage of the limit.
5557
*/
5658
export const MessageThreshold: Story = {
57-
render: () => (
59+
render: (args) => (
5860
<CharacterCount
5961
label="Can you provide more detail?"
6062
labelProps={{ isPageHeading: true, size: 'l' }}
@@ -63,6 +65,7 @@ export const MessageThreshold: Story = {
6365
maxLength={112}
6466
threshold={75}
6567
rows={5}
68+
{...args}
6669
/>
6770
),
6871
};

stories/Form Elements/Checkboxes.stories.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const Standard: Story = {
5353
idPrefix={args.idPrefix}
5454
name="nationality"
5555
id="nationality"
56+
{...args}
5657
>
5758
<Checkboxes.Item value="british">British</Checkboxes.Item>
5859
<Checkboxes.Item value="irish">Irish</Checkboxes.Item>
@@ -68,6 +69,7 @@ export const WithHintText: Story = {
6869
<Checkboxes
6970
legend="How do you want to sign in?"
7071
legendProps={{ isPageHeading: true, size: 'l' }}
72+
{...args}
7173
>
7274
<Checkboxes.Item
7375
id="government-gateway"
@@ -94,7 +96,7 @@ export const WithHintText: Story = {
9496
export const WithDisabledItem: Story = {
9597
render: (args) => (
9698
<form>
97-
<Checkboxes id="colours" name="colours">
99+
<Checkboxes id="colours" name="colours" {...args}>
98100
<Checkboxes.Item value="red">Red</Checkboxes.Item>
99101
<Checkboxes.Item value="green">Green</Checkboxes.Item>
100102
<Checkboxes.Item value="red" disabled>
@@ -114,6 +116,7 @@ export const WithConditionalContent: Story = {
114116
hint="Select all that apply"
115117
id="waste"
116118
name="waste"
119+
{...args}
117120
>
118121
<Checkboxes.Item conditional={<p>This includes rocks and earth.</p>} value="mines">
119122
Waste from mines or quarries
@@ -132,6 +135,7 @@ export const WithExclusiveNoneOption: Story = {
132135
hint="Select all the symptoms you have"
133136
id="symptoms"
134137
name="symptoms"
138+
{...args}
135139
>
136140
<Checkboxes.Item value="sore-throat">Sore throat</Checkboxes.Item>
137141
<Checkboxes.Item value="runny-nose">Runny nose</Checkboxes.Item>
@@ -158,6 +162,7 @@ export const WithError: Story = {
158162
error={error}
159163
id="waste"
160164
name="waste"
165+
{...args}
161166
>
162167
<Checkboxes.Item value="animal">Waste from animal carcasses</Checkboxes.Item>
163168
<Checkboxes.Item value="mines">Waste from mines or quarries</Checkboxes.Item>
@@ -175,7 +180,7 @@ export const WithError: Story = {
175180
};
176181

177182
export const NoIDSupplied: Story = {
178-
render: function NoIDSuppliedRender() {
183+
render: function NoIDSuppliedRender(args) {
179184
const checkbox1Ref = useRef<HTMLInputElement>(null);
180185
const checkbox2Ref = useRef<HTMLInputElement>(null);
181186
const checkbox3Ref = useRef<HTMLInputElement>(null);
@@ -248,7 +253,7 @@ export const NoIDSupplied: Story = {
248253
</li>
249254
</ul>
250255
<h5>Component</h5>
251-
<Checkboxes>
256+
<Checkboxes {...args}>
252257
<Checkboxes.Item ref={checkbox1Ref}>Box 1</Checkboxes.Item>
253258
<Checkboxes.Item ref={checkbox2Ref}>Box 2</Checkboxes.Item>
254259
<Checkboxes.Item ref={checkbox3Ref}>Box 3</Checkboxes.Item>
@@ -259,7 +264,7 @@ export const NoIDSupplied: Story = {
259264
};
260265

261266
export const NameSupplied: Story = {
262-
render: function NameSuppliedRender() {
267+
render: function NameSuppliedRender(args) {
263268
const checkbox1Ref = useRef<HTMLInputElement>(null);
264269
const checkbox2Ref = useRef<HTMLInputElement>(null);
265270
const checkbox3Ref = useRef<HTMLInputElement>(null);
@@ -332,7 +337,7 @@ export const NameSupplied: Story = {
332337
</li>
333338
</ul>
334339
<h5>Component</h5>
335-
<Checkboxes name="name-supplied">
340+
<Checkboxes name="name-supplied" {...args}>
336341
<Checkboxes.Item ref={checkbox1Ref}>Box 1</Checkboxes.Item>
337342
<Checkboxes.Item ref={checkbox2Ref}>Box 2</Checkboxes.Item>
338343
<Checkboxes.Item ref={checkbox3Ref}>Box 3</Checkboxes.Item>
@@ -343,7 +348,7 @@ export const NameSupplied: Story = {
343348
};
344349

345350
export const IDPrefixSupplied: Story = {
346-
render: function IDPrefixSuppliedRender() {
351+
render: function IDPrefixSuppliedRender(args) {
347352
const checkbox1Ref = useRef<HTMLInputElement>(null);
348353
const checkbox2Ref = useRef<HTMLInputElement>(null);
349354
const checkbox3Ref = useRef<HTMLInputElement>(null);
@@ -417,7 +422,7 @@ export const IDPrefixSupplied: Story = {
417422
</li>
418423
</ul>
419424
<h5>Component</h5>
420-
<Checkboxes idPrefix="idprefix">
425+
<Checkboxes idPrefix="idprefix" {...args}>
421426
<Checkboxes.Item ref={checkbox1Ref}>Box 1</Checkboxes.Item>
422427
<Checkboxes.Item ref={checkbox2Ref}>Box 2</Checkboxes.Item>
423428
<Checkboxes.Item ref={checkbox3Ref}>Box 3</Checkboxes.Item>
@@ -428,7 +433,7 @@ export const IDPrefixSupplied: Story = {
428433
};
429434

430435
export const IDPrefixAndNameSupplied: Story = {
431-
render: function IDPrefixAndNameSuppliedRender() {
436+
render: function IDPrefixAndNameSuppliedRender(args) {
432437
const checkbox1Ref = useRef<HTMLInputElement>(null);
433438
const checkbox2Ref = useRef<HTMLInputElement>(null);
434439
const checkbox3Ref = useRef<HTMLInputElement>(null);
@@ -502,7 +507,7 @@ export const IDPrefixAndNameSupplied: Story = {
502507
</li>
503508
</ul>
504509
<h5>Component</h5>
505-
<Checkboxes idPrefix="idprefix" name="testname">
510+
<Checkboxes idPrefix="idprefix" name="testname" {...args}>
506511
<Checkboxes.Item ref={checkbox1Ref}>Box 1</Checkboxes.Item>
507512
<Checkboxes.Item ref={checkbox2Ref}>Box 2</Checkboxes.Item>
508513
<Checkboxes.Item ref={checkbox3Ref}>Box 3</Checkboxes.Item>
@@ -513,7 +518,7 @@ export const IDPrefixAndNameSupplied: Story = {
513518
};
514519

515520
export const OnChangeAndOnInputHandlers: Story = {
516-
render: function OnChangeAndOnInputHandlersRender() {
521+
render: function OnChangeAndOnInputHandlersRender(args) {
517522
const [changeEventLog, setChangeEventLog] = useState<Array<string>>([]);
518523
const [inputEventLog, setInputEventLog] = useState<Array<string>>([]);
519524
const [currentValue, setCurrentValue] = useState<Array<string>>([]);
@@ -548,7 +553,7 @@ export const OnChangeAndOnInputHandlers: Story = {
548553
<li>The value is passed through</li>
549554
</ul>
550555
<h5>Component</h5>
551-
<Checkboxes onChange={handleChange} onInput={handleInput}>
556+
<Checkboxes onChange={handleChange} onInput={handleInput} {...args}>
552557
<Checkboxes.Item value="1">Box 1</Checkboxes.Item>
553558
<Checkboxes.Item value="2">Box 2</Checkboxes.Item>
554559
<Checkboxes.Item value="3">Box 3</Checkboxes.Item>

0 commit comments

Comments
 (0)