Skip to content

Commit f707dbc

Browse files
Make sure stories update when args change (#290)
* Use `defaultValue` and `defaultChecked` without change handlers * Update form examples with `isPageHeading` * Always pass args to storybook examples * Remove out of date comment * Remove unnecessary wrappers * Remove implementation notes duplicated in args or examples
1 parent 95c2c41 commit f707dbc

28 files changed

+494
-760
lines changed

src/components/navigation/action-link/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This component can be found in the `nhsuk-frontend` repository [here](https://github.com/nhsuk/nhsuk-frontend/tree/main/packages/nhsuk-frontend/src/nhsuk/components/action-link).
44

5-
## Implementation Notes
5+
## Implementation notes
66

77
The ActionLink component does not use the `nhsuk-frontend` "openInNewWindow" property, instead it allows the user to add the `target="_blank"` property (if desired).
88

stories/Content Presentation/Details.stories.tsx

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,13 @@ import { Details } from '#components';
44
/**
55
* This component can be found in the `nhsuk-frontend` repository <a href="https://github.com/nhsuk/nhsuk-frontend/tree/main/packages/nhsuk-frontend/src/nhsuk/components/contents-list" target="_blank">here</a>.
66
*
7-
* ## Implementation Notes
7+
* ## Implementation notes
88
*
99
* The `Details` component has three subcomponents:
1010
*
1111
* - `Details.Summary`
1212
* - `Details.Text`
1313
* - `Details.ExpanderGroup`
14-
*
15-
* ## Usage
16-
*
17-
* ### Standard
18-
*
19-
* ```jsx
20-
* import { Details } from "nhsuk-react-components";
21-
*
22-
* const Element = () => {
23-
* return (
24-
* <Details>
25-
* <Details.Summary>Where can I find my NHS number?</Details.Summary>
26-
* <Details.Text>
27-
* <p>An NHS number is a 10 digit number, like 485 777 3456.</p>
28-
* <p>
29-
* You can find your NHS number on any document sent to you by the NHS. This may include:
30-
* </p>
31-
* <ul>
32-
* <li>prescriptions</li>
33-
* <li>test results</li>
34-
* <li>hospital referral letters</li>
35-
* <li>appointment letters</li>
36-
* <li>your NHS medical card</li>
37-
* </ul>
38-
* <p>Ask your GP practice for help if you can't find your NHS number.</p>
39-
* </Details.Text>
40-
* </Details>
41-
* );
42-
* }
43-
* ```
4414
*/
4515
const meta: Meta<typeof Details> = {
4616
title: 'Content Presentation/Details',

stories/Content Presentation/DoAndDontList.stories.tsx

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,15 @@ import { DoAndDontList } from '#components';
44
/**
55
* This component can be found in the `nhsuk-frontend` repository <a href="https://github.com/nhsuk/nhsuk-frontend/tree/main/packages/nhsuk-frontend/src/nhsuk/components/do-dont-list" target="_blank" rel="noopener noreferrer">here</a>.
66
*
7-
* ## Implementation Notes
7+
* ## Implementation notes
88
*
99
* The `DoAndDontList` component has one subcomponent: `DoAndDontList.Item`.
1010
*
1111
* As long as a `listType` is supplied to the `DoAndDontList` component, all subcomponents will render as desired. If you require a `DoAndDontList.Item` to be different, a `listItemType` prop can be supplied to force the type.
1212
*
13-
*
1413
* The `DoAndDontList.Item` component can also accept a `prefixText` prop, which can be used to override the default prefix text.
1514
*
1615
* See the <b><a href="#custom-prefix-text" >custom prefix text</a></b> story for an example.
17-
*
18-
* ## Usage
19-
*
20-
* ### Standard
21-
*
22-
* ```jsx
23-
* import { DoAndDontList } from "nhsuk-react-components";
24-
*
25-
* const Element = () => {
26-
* return (
27-
* <DoAndDontList listType="do">
28-
* <DoAndDontList.Item>
29-
* cover blisters that are likely to burst with a soft plaster or dressing
30-
* </DoAndDontList.Item>
31-
* <DoAndDontList.Item>wash your hands before touching a burst blister</DoAndDontList.Item>
32-
* <DoAndDontList.Item>
33-
* allow the fluid in a burst blister to drain before covering it with a plaster or dressing
34-
* </DoAndDontList.Item>
35-
* </DoAndDontList>
36-
* );
37-
* }
38-
* ```
3916
*/
4017
const meta: Meta<typeof DoAndDontList> = {
4118
title: 'Content Presentation/DoAndDontList',
@@ -45,8 +22,11 @@ export default meta;
4522
type Story = StoryObj<typeof DoAndDontList>;
4623

4724
export const Do: Story = {
25+
args: {
26+
listType: 'do',
27+
},
4828
render: (args) => (
49-
<DoAndDontList listType="do">
29+
<DoAndDontList {...args}>
5030
<DoAndDontList.Item>
5131
cover blisters that are likely to burst with a soft plaster or dressing
5232
</DoAndDontList.Item>
@@ -59,8 +39,11 @@ export const Do: Story = {
5939
};
6040

6141
export const Dont: Story = {
42+
args: {
43+
listType: 'dont',
44+
},
6245
render: (args) => (
63-
<DoAndDontList listType="dont">
46+
<DoAndDontList {...args}>
6447
<DoAndDontList.Item>burst a blister yourself</DoAndDontList.Item>
6548
<DoAndDontList.Item>peel the skin off a burst blister</DoAndDontList.Item>
6649
<DoAndDontList.Item>pick at the edges of the remaining skin</DoAndDontList.Item>
@@ -90,8 +73,11 @@ export const Dont: Story = {
9073
* | JSX | The JSX will be rendered, such as `<span>` |
9174
*/
9275
export const CustomPrefixText: Story = {
93-
render: () => (
94-
<DoAndDontList listType="dont">
76+
args: {
77+
listType: 'dont',
78+
},
79+
render: (args) => (
80+
<DoAndDontList {...args}>
9581
<DoAndDontList.Item prefixText="You must not">burst a blister yourself</DoAndDontList.Item>
9682
<DoAndDontList.Item prefixText={undefined}>
9783
peel the skin off a burst blister

stories/Content Presentation/NotificationBanner.stories.tsx

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,13 @@ import { NotificationBannerLink } from '#components/content-presentation/notific
55
/**
66
* This component can be found in the `nhsuk-frontend` repository <a href="https://github.com/nhsuk/nhsuk-frontend/tree/main/packages/nhsuk-frontend/src/nhsuk/components/notification-banner" target="_blank">here</a>.
77
*
8-
* ## Implementation Notes
8+
* ## Implementation notes
99
*
1010
* The `NotificationBanner` component has three subcomponents:
1111
*
1212
* - `NotificationBanner.Title`
1313
* - `NotificationBanner.Heading`
1414
* - `NotificationBanner.Link`
15-
*
16-
* ## Usage
17-
*
18-
* ### Standard
19-
*
20-
* ```jsx
21-
* import { NotificationBanner } from "nhsuk-react-components";
22-
*
23-
* const Element = () => {
24-
* return (
25-
* <NotificationBanner>
26-
* <NotificationBanner.Heading>Patient record updated</Details.Summary>
27-
* <p>
28-
* Contact <NotificationBanner.Link href="#">example@department.nhs.uk</NotificationBanner.Link> if you think there&#39;s a problem.
29-
* </p>
30-
* </NotificationBanner>
31-
* );
32-
* }
33-
* ```
3415
*/
3516
const meta: Meta<typeof NotificationBanner> = {
3617
title: 'Content Presentation/Notification Banner',
@@ -41,8 +22,8 @@ type Story = StoryObj<typeof NotificationBanner>;
4122

4223
export const StandardPanel: Story = {
4324
args: {},
44-
render: () => (
45-
<NotificationBanner>
25+
render: (args) => (
26+
<NotificationBanner {...args}>
4627
<NotificationBanner.Heading>
4728
The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025.
4829
</NotificationBanner.Heading>
@@ -51,9 +32,11 @@ export const StandardPanel: Story = {
5132
};
5233

5334
export const SuccessPanel: Story = {
54-
args: {},
55-
render: () => (
56-
<NotificationBanner success>
35+
args: {
36+
success: true,
37+
},
38+
render: (args) => (
39+
<NotificationBanner {...args}>
5740
<NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading>
5841
<p>
5942
Contact{' '}
@@ -66,8 +49,8 @@ export const SuccessPanel: Story = {
6649

6750
export const StandardPanelWithLink: Story = {
6851
args: {},
69-
render: () => (
70-
<NotificationBanner>
52+
render: (args) => (
53+
<NotificationBanner {...args}>
7154
<NotificationBanner.Heading>
7255
You have 7 days left to send your application.{' '}
7356
<NotificationBanner.Link href="#">View application</NotificationBanner.Link>.
@@ -80,8 +63,8 @@ export const StandardPanelWithCustomTitle: Story = {
8063
args: {
8164
title: 'Important Message',
8265
},
83-
render: () => (
84-
<NotificationBanner>
66+
render: (args) => (
67+
<NotificationBanner {...args}>
8568
<NotificationBanner.Heading>Upcoming maintenance</NotificationBanner.Heading>
8669
<p>The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025.</p>
8770
</NotificationBanner>
@@ -90,8 +73,8 @@ export const StandardPanelWithCustomTitle: Story = {
9073

9174
export const StandardPanelWithCustomTitleElement: Story = {
9275
args: {},
93-
render: () => (
94-
<NotificationBanner>
76+
render: (args) => (
77+
<NotificationBanner {...args}>
9578
<NotificationBanner.Title>
9679
Maintenance <time dateTime="2025-01-01">January 1</time>
9780
</NotificationBanner.Title>
@@ -103,8 +86,8 @@ export const StandardPanelWithCustomTitleElement: Story = {
10386

10487
export const StandardPanelWithList: Story = {
10588
args: {},
106-
render: () => (
107-
<NotificationBanner>
89+
render: (args) => (
90+
<NotificationBanner {...args}>
10891
<NotificationBanner.Heading>4 files uploaded</NotificationBanner.Heading>
10992
<ul>
11093
<li>
@@ -126,8 +109,8 @@ export const StandardPanelWithList: Story = {
126109

127110
export const StandardPanelWithLotsOfContent: Story = {
128111
args: {},
129-
render: () => (
130-
<NotificationBanner>
112+
render: (args) => (
113+
<NotificationBanner {...args}>
131114
<NotificationBanner.Heading>
132115
Check if you need to apply the reverse charge to this application
133116
</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/Button.stories.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ import { Button } from '#components';
44
/**
55
* This component can be found in the `nhsuk-frontend` repository <a href="https://github.com/nhsuk/nhsuk-frontend/tree/main/packages/components/button" target="_blank" rel="noopener noreferrer">here</a>.
66
*
7-
* ## Implementation Notes
7+
* ## Implementation notes
88
*
99
* The `Button` component from `nhsuk-react-components` will either render a standard `<button>` or `<a>` element depending on whether an `href` prop is supplied.
1010
*
1111
* If you want to use a specific component instead of the wrapper, you can supply the `as="a"` or `as="button"` props.
1212
*
1313
* ## Usage
1414
*
15-
* ### Standard
15+
* ### As a button
1616
*
1717
* ```jsx
1818
* import { Button } from "nhsuk-react-components";
1919
*
2020
* const Element = () => {
21-
* return (
22-
* <Button>Button</Button>
23-
* );
21+
* return (
22+
* <Button>Button</Button>
23+
* );
2424
* }
2525
* ```
2626
*
27-
* ### As a Link
27+
* ### As a link
2828
*
2929
* ```jsx
3030
* import { Button } from "nhsuk-react-components";
3131
*
3232
* const ButtonEl = () => (
33-
* <Button as="a">Anchor</Button>
33+
* <Button as="a">Anchor</Button>
3434
* );
3535
*
3636
* const ButtonEl2 = () => (
37-
* <Button href="/link">Anchor</Button>
37+
* <Button href="/link">Anchor</Button>
3838
* );
3939
* ```
4040
*/

0 commit comments

Comments
 (0)