From 3dfb26fe60cf80ea5fbb6b9a5606318f976443b0 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Wed, 13 May 2026 17:47:26 +0100 Subject: [PATCH 1/8] Directly use pre-built CSS from NHS.UK frontend --- .storybook/main.ts | 4 +++- .storybook/preview-head.html | 1 + .storybook/storybook.scss | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .storybook/preview-head.html diff --git a/.storybook/main.ts b/.storybook/main.ts index 5de8735aa..6f8dca60c 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -4,13 +4,15 @@ import { type InlineConfig, mergeConfig } from 'vite'; import tsConfigPaths from 'vite-tsconfig-paths'; const config: StorybookConfig = { - stories: ['../stories/**/*.stories.@(ts|tsx)', '../stories/**/*.mdx'], addons: ['@storybook/addon-links', '@storybook/addon-docs'], framework: { name: '@storybook/react-vite', options: {}, }, + staticDirs: ['../node_modules/nhsuk-frontend/dist/nhsuk'], + stories: ['../stories/**/*.stories.@(ts|tsx)', '../stories/**/*.mdx'], + typescript: { reactDocgen: 'react-docgen-typescript', }, diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html new file mode 100644 index 000000000..5a85c1381 --- /dev/null +++ b/.storybook/preview-head.html @@ -0,0 +1 @@ + diff --git a/.storybook/storybook.scss b/.storybook/storybook.scss index ea4b70a2d..1cf1ac123 100644 --- a/.storybook/storybook.scss +++ b/.storybook/storybook.scss @@ -1,5 +1,3 @@ -@forward 'nhsuk-frontend/dist/nhsuk'; - .tag-wrapper { display: flex; flex-direction: column; From 48d75e6250455a4efdf9153be2ee2baf18368d5f Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Wed, 13 May 2026 17:49:03 +0100 Subject: [PATCH 2/8] Update checkbox stories to use `defaultChecked` (i.e. no `onChange` handler) --- stories/Form Elements/Checkboxes.stories.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stories/Form Elements/Checkboxes.stories.tsx b/stories/Form Elements/Checkboxes.stories.tsx index 9ae0533d8..3e424addf 100644 --- a/stories/Form Elements/Checkboxes.stories.tsx +++ b/stories/Form Elements/Checkboxes.stories.tsx @@ -104,7 +104,7 @@ export const WithValues: Story = { Date: Wed, 13 May 2026 19:30:07 +0100 Subject: [PATCH 3/8] Update component error stories to avoid state --- stories/Form Elements/Radios.stories.tsx | 26 +++++++--------------- stories/Form Elements/Textarea.stories.tsx | 15 +++---------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/stories/Form Elements/Radios.stories.tsx b/stories/Form Elements/Radios.stories.tsx index f9f817322..d658380de 100644 --- a/stories/Form Elements/Radios.stories.tsx +++ b/stories/Form Elements/Radios.stories.tsx @@ -1,9 +1,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite'; -import { useState } from 'react'; import { Checkboxes } from '#components/form-elements/checkboxes/index.js'; import { Radios } from '#components/form-elements/radios/index.js'; -import { TextInput } from '#components/form-elements/text-input/index.js'; const meta: Meta = { title: 'Form Elements/Radios', @@ -205,23 +203,15 @@ export const DisabledRadios: Story = { }; export const RadiosWithError: Story = { + name: 'Radios with error message', args: { + error: 'Select yes if you have changed your name', idPrefix: 'error', }, - render: function RadiosWithErrorRender(args) { - const [error, setError] = useState('Select yes if you have changed your name'); - return ( - <> - - Yes - - No - - - setError(e.currentTarget.value)} /> - - ); - }, - - name: 'Radios With Error (String)', + render: (args) => ( + + Yes + No + + ), }; diff --git a/stories/Form Elements/Textarea.stories.tsx b/stories/Form Elements/Textarea.stories.tsx index d038be2f4..cbe970e36 100644 --- a/stories/Form Elements/Textarea.stories.tsx +++ b/stories/Form Elements/Textarea.stories.tsx @@ -1,7 +1,5 @@ import { type Meta, type StoryObj } from '@storybook/react-vite'; -import { useState } from 'react'; -import { TextInput } from '#components/form-elements/text-input/index.js'; import { Textarea } from '#components/form-elements/textarea/index.js'; const meta: Meta = { @@ -28,15 +26,8 @@ export const TextareaWithAutoCompleteAttribute: Story = { }; export const TextareaWithError: Story = { - render: function TextareaWithErrorRender(args) { - const [error, setError] = useState('You must provide an explanation'); - return ( - <> -