Skip to content

Commit 955aef1

Browse files
docs(storybook): improve details family docs pages
1 parent 550bc2d commit 955aef1

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

packages/react-components/src/components/Details/Details.stories.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react-vite';
2+
import { ArgTypes, Description, Source, Stories, Title } from '@storybook/addon-docs/blocks';
23
import { Details } from './Details';
34

45
const defaultDetailsCode = `import { Details } from '@ourfuturehealth/react-components';
@@ -29,6 +30,13 @@ const richContentDetailsCode = `import { Details } from '@ourfuturehealth/react-
2930
</Details>;
3031
`;
3132

33+
const detailsUsageExample = `import { Details } from '@ourfuturehealth/react-components';
34+
35+
<Details summary="Where can I find my NHS number?">
36+
An NHS number is a 10 digit number, like 485 777 3456.
37+
</Details>;
38+
`;
39+
3240
const meta: Meta<typeof Details> = {
3341
title: 'Components/Details',
3442
component: Details,
@@ -39,6 +47,32 @@ const meta: Meta<typeof Details> = {
3947
component:
4048
'Use Details to make a page easier to scan when only some users need supporting information. The React API is intentionally small: `summary` is the clickable label, `open` controls the initial expanded state, and `children` is the content shown inside the disclosure panel. Prefer Expander when the content is more important, aimed at a wider audience, or needs more visual prominence.',
4149
},
50+
page: () => (
51+
<>
52+
<Title />
53+
<Description />
54+
55+
<h2>How to use the React component</h2>
56+
<p>
57+
Use <code>Details</code> when the disclosure is supporting
58+
information that only some users will need. Pass the clickable
59+
label through <code>summary</code> and the hidden content through{' '}
60+
<code>children</code>.
61+
</p>
62+
<p>
63+
Set <code>open</code> only when the content should be expanded on
64+
first render. If the content is more prominent or intended for a
65+
wider audience, use <code>Expander</code> instead.
66+
</p>
67+
<Source code={detailsUsageExample} language="tsx" />
68+
69+
<h2>Component props</h2>
70+
<ArgTypes of={Details} exclude={['ref']} />
71+
72+
<h2>Examples</h2>
73+
<Stories title="Examples" />
74+
</>
75+
),
4276
},
4377
},
4478
tags: ['autodocs'],

packages/react-components/src/components/Expander/Expander.stories.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Meta, StoryObj } from '@storybook/react-vite';
2+
import { ArgTypes, Description, Source, Stories, Title } from '@storybook/addon-docs/blocks';
23
import { Expander } from './Expander';
34

45
const defaultExpanderCode = `import { Expander } from '@ourfuturehealth/react-components';
@@ -41,6 +42,13 @@ const groupedExpanderCode = `import { Expander } from '@ourfuturehealth/react-co
4142
</div>;
4243
`;
4344

45+
const expanderUsageExample = `import { Expander } from '@ourfuturehealth/react-components';
46+
47+
<Expander summary="Opening times">
48+
We are open Monday to Friday, 9am to 6pm.
49+
</Expander>;
50+
`;
51+
4452
const meta: Meta<typeof Expander> = {
4553
title: 'Components/Expander',
4654
component: Expander,
@@ -51,6 +59,32 @@ const meta: Meta<typeof Expander> = {
5159
component:
5260
'Use Expander when users may feel overwhelmed by the amount of information and need it broken into smaller sections. The React API is intentionally small: `summary` is the clickable label, `open` controls the initial expanded state, and `children` is the content shown inside the disclosure panel. Prefer Details when only some users need the content and the disclosure should stay visually lighter.',
5361
},
62+
page: () => (
63+
<>
64+
<Title />
65+
<Description />
66+
67+
<h2>How to use the React component</h2>
68+
<p>
69+
Use <code>Expander</code> when a larger block of information needs
70+
to be broken into smaller sections without losing prominence. Pass
71+
the clickable label through <code>summary</code> and the disclosure
72+
content through <code>children</code>.
73+
</p>
74+
<p>
75+
Set <code>open</code> when the section should be expanded on first
76+
render. If the disclosure is lighter-weight supporting information,
77+
prefer <code>Details</code>.
78+
</p>
79+
<Source code={expanderUsageExample} language="tsx" />
80+
81+
<h2>Component props</h2>
82+
<ArgTypes of={Expander} exclude={['ref']} />
83+
84+
<h2>Examples</h2>
85+
<Stories title="Examples" />
86+
</>
87+
),
5488
},
5589
},
5690
tags: ['autodocs'],

0 commit comments

Comments
 (0)