Skip to content

Commit cff7c1a

Browse files
committed
chore: update storybook
1 parent 2ee6aee commit cff7c1a

40 files changed

+430
-1113
lines changed

.storybook/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import type { StorybookConfig } from "@storybook/react-webpack5";
66
import type { Indexer } from "storybook/internal/types";
77
import { loadCsf } from "storybook/internal/csf-tools";
88
import { serverRequire } from "storybook/internal/common";
9-
import sass from "sass";
9+
import * as sass from "sass";
1010
import { compile } from "./compile.ts";
1111
import { vite, webpack, STORIES_REGEX } from "./unplugin.ts";
1212

13+
const __filename = fileURLToPath(import.meta.url);
14+
1315
const require = createRequire(import.meta.url);
1416
const __dirname = dirname(fileURLToPath(import.meta.url));
1517

package-lock.json

Lines changed: 81 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@
6868
"@rollup/plugin-node-resolve": "^16.0.3",
6969
"@rollup/plugin-terser": "^1.0.0",
7070
"@rollup/plugin-typescript": "^12.3.0",
71-
"@storybook/addon-a11y": "^10.2.19",
72-
"@storybook/addon-links": "^10.2.19",
71+
"@storybook/addon-a11y": "^10.3.0",
72+
"@storybook/addon-links": "^10.3.0",
7373
"@storybook/addon-styling-webpack": "^3.0.0",
7474
"@storybook/addon-webpack5-compiler-swc": "^4.0.2",
75-
"@storybook/csf": "^0.1.13",
76-
"@storybook/react-vite": "^10.2.19",
77-
"@storybook/react-webpack5": "^10.2.19",
78-
"@storybook/test-runner": "^0.24.2",
75+
"@storybook/react-vite": "^10.3.0",
76+
"@storybook/react-webpack5": "^10.3.0",
77+
"@storybook/test-runner": "^0.24.3",
7978
"@testing-library/jest-dom": "^6.9.1",
8079
"@testing-library/react": "^16.3.2",
8180
"@types/govuk-frontend": "^5.11.0",
@@ -91,7 +90,7 @@
9190
"deep-iterator": "^1.1.0",
9291
"eslint": "^9.37.0",
9392
"eslint-plugin-react": "^7.37.5",
94-
"eslint-plugin-storybook": "^10.2.19",
93+
"eslint-plugin-storybook": "^10.3.0",
9594
"globals": "^17.4.0",
9695
"govuk-frontend": "^6.1.0",
9796
"html-react-parser": "^5.2.17",
@@ -119,7 +118,7 @@
119118
"sass": "^1.98.0",
120119
"sass-loader": "^16.0.7",
121120
"standard-version": "^9.5.0",
122-
"storybook": "^10.2.19",
121+
"storybook": "^10.3.0",
123122
"style-loader": "^4.0.0",
124123
"stylelint": "^17.4.0",
125124
"stylelint-config-recess-order": "^7.6.1",
@@ -132,7 +131,7 @@
132131
"typescript-eslint": "^8.57.1",
133132
"unplugin": "^3.0.0",
134133
"webpack": "^5.105.4",
135-
"@storybook/addon-docs": "^10.2.19"
134+
"@storybook/addon-docs": "^10.3.0"
136135
},
137136
"peerDependencies": {
138137
"govuk-frontend": ">=5.14.0",
@@ -172,4 +171,4 @@
172171
"dependencies": {
173172
"ts-dedent": "^2.2.0"
174173
}
175-
}
174+
}

src/components/Accordion/Accordion.stories.tsx

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ let configured = false;
1515
const meta: Meta<typeof Accordion> = {
1616
title: "GOVUK Design System/Accordion",
1717
component: Accordion,
18-
decorators: [
19-
(Story, { parameters }) => {
18+
decorators: [(Story, { parameters }) => {
2019
React.useEffect(() => {
21-
const isDocsMode = window.location.search.includes(
22-
"path=/docs/govuk-design-system-accordion--docs",
23-
);
20+
const isDocsMode = window.location.search.includes("path=/docs/govuk-design-system-accordion--docs");
2421
if (isDocsMode && !configured && parameters.initializeConfigurations) {
2522
ConfigureOverallAccordion();
2623
configured = true;
@@ -29,8 +26,7 @@ const meta: Meta<typeof Accordion> = {
2926
}
3027
}, []);
3128
return <Story />;
32-
},
33-
],
29+
}],
3430
tags: ["autodocs"],
3531
};
3632

@@ -39,8 +35,7 @@ type Story = StoryObj<typeof Accordion>;
3935

4036
// extractShownFixtures transforms raw govuk-frontend fixture data into
4137
// React-compatible props (e.g. text → children, classes → className).
42-
const examplesFromFixtures: Array<ComponentFixture> =
43-
extractShownFixtures(fixtures);
38+
const examplesFromFixtures: Array<ComponentFixture> = extractShownFixtures(fixtures);
4439

4540
export const Default: Story = {
4641
name: "default",
@@ -49,27 +44,15 @@ export const Default: Story = {
4944

5045
export const WithAdditionalDescriptions: Story = {
5146
name: "with additional descriptions",
52-
args: {
53-
...examplesFromFixtures.find(
54-
(f) => f.name === "with additional descriptions",
55-
)?.options,
56-
},
47+
args: { ...examplesFromFixtures.find((f) => f.name === "with additional descriptions")?.options },
5748
};
5849

5950
export const WithLongContentAndDescription: Story = {
6051
name: "with long content and description",
61-
args: {
62-
...examplesFromFixtures.find(
63-
(f) => f.name === "with long content and description",
64-
)?.options,
65-
},
52+
args: { ...examplesFromFixtures.find((f) => f.name === "with long content and description")?.options },
6653
};
6754

6855
export const WithAllSectionsAlreadyOpen: Story = {
6956
name: "with all sections already open",
70-
args: {
71-
...examplesFromFixtures.find(
72-
(f) => f.name === "with all sections already open",
73-
)?.options,
74-
},
75-
};
57+
args: { ...examplesFromFixtures.find((f) => f.name === "with all sections already open")?.options },
58+
};

src/components/BackLink/BackLink.stories.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import { ComponentFixture } from "../../dynamics";
1212
const meta: Meta<typeof BackLink> = {
1313
title: "GOVUK Design System/Back link",
1414
component: BackLink,
15-
decorators: [
16-
(Story) => {
15+
decorators: [(Story) => {
1716
return <Story />;
18-
},
19-
],
17+
}],
2018
tags: ["autodocs"],
2119
};
2220

@@ -25,8 +23,7 @@ type Story = StoryObj<typeof BackLink>;
2523

2624
// extractShownFixtures transforms raw govuk-frontend fixture data into
2725
// React-compatible props (e.g. text → children, classes → className).
28-
const examplesFromFixtures: Array<ComponentFixture> =
29-
extractShownFixtures(fixtures);
26+
const examplesFromFixtures: Array<ComponentFixture> = extractShownFixtures(fixtures);
3027

3128
export const Default: Story = {
3229
name: "default",
@@ -36,4 +33,4 @@ export const Default: Story = {
3633
export const Inverse: Story = {
3734
name: "inverse",
3835
args: { ...examplesFromFixtures.find((f) => f.name === "inverse")?.options },
39-
};
36+
};

src/components/Breadcrumbs/Breadcrumbs.stories.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import { ComponentFixture } from "../../dynamics";
1212
const meta: Meta<typeof Breadcrumbs> = {
1313
title: "GOVUK Design System/Breadcrumbs",
1414
component: Breadcrumbs,
15-
decorators: [
16-
(Story) => {
15+
decorators: [(Story) => {
1716
return <Story />;
18-
},
19-
],
17+
}],
2018
tags: ["autodocs"],
2119
};
2220

@@ -25,8 +23,7 @@ type Story = StoryObj<typeof Breadcrumbs>;
2523

2624
// extractShownFixtures transforms raw govuk-frontend fixture data into
2725
// React-compatible props (e.g. text → children, classes → className).
28-
const examplesFromFixtures: Array<ComponentFixture> =
29-
extractShownFixtures(fixtures);
26+
const examplesFromFixtures: Array<ComponentFixture> = extractShownFixtures(fixtures);
3027

3128
export const Default: Story = {
3229
name: "default",
@@ -35,37 +32,25 @@ export const Default: Story = {
3532

3633
export const WithOneLevel: Story = {
3734
name: "with one level",
38-
args: {
39-
...examplesFromFixtures.find((f) => f.name === "with one level")?.options,
40-
},
35+
args: { ...examplesFromFixtures.find((f) => f.name === "with one level")?.options },
4136
};
4237

4338
export const WithoutTheHomeSection: Story = {
4439
name: "without the home section",
45-
args: {
46-
...examplesFromFixtures.find((f) => f.name === "without the home section")
47-
?.options,
48-
},
40+
args: { ...examplesFromFixtures.find((f) => f.name === "without the home section")?.options },
4941
};
5042

5143
export const WithLastBreadcrumbAsCurrentPage: Story = {
5244
name: "with last breadcrumb as current page",
53-
args: {
54-
...examplesFromFixtures.find(
55-
(f) => f.name === "with last breadcrumb as current page",
56-
)?.options,
57-
},
45+
args: { ...examplesFromFixtures.find((f) => f.name === "with last breadcrumb as current page")?.options },
5846
};
5947

6048
export const WithCollapseOnMobile: Story = {
6149
name: "with collapse on mobile",
62-
args: {
63-
...examplesFromFixtures.find((f) => f.name === "with collapse on mobile")
64-
?.options,
65-
},
50+
args: { ...examplesFromFixtures.find((f) => f.name === "with collapse on mobile")?.options },
6651
};
6752

6853
export const Inverse: Story = {
6954
name: "inverse",
7055
args: { ...examplesFromFixtures.find((f) => f.name === "inverse")?.options },
71-
};
56+
};

src/components/Button/Button.stories.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ let configured = false;
1515
const meta: Meta<typeof Button> = {
1616
title: "GOVUK Design System/Button",
1717
component: Button,
18-
decorators: [
19-
(Story, { parameters }) => {
18+
decorators: [(Story, { parameters }) => {
2019
React.useEffect(() => {
21-
const isDocsMode = window.location.search.includes(
22-
"path=/docs/govuk-design-system-button--docs",
23-
);
20+
const isDocsMode = window.location.search.includes("path=/docs/govuk-design-system-button--docs");
2421
if (isDocsMode && !configured && parameters.initializeConfigurations) {
2522
ConfigureOverallButton();
2623
configured = true;
@@ -29,8 +26,7 @@ const meta: Meta<typeof Button> = {
2926
}
3027
}, []);
3128
return <Story />;
32-
},
33-
],
29+
}],
3430
tags: ["autodocs"],
3531
};
3632

@@ -39,8 +35,7 @@ type Story = StoryObj<typeof Button>;
3935

4036
// extractShownFixtures transforms raw govuk-frontend fixture data into
4137
// React-compatible props (e.g. text → children, classes → className).
42-
const examplesFromFixtures: Array<ComponentFixture> =
43-
extractShownFixtures(fixtures);
38+
const examplesFromFixtures: Array<ComponentFixture> = extractShownFixtures(fixtures);
4439

4540
export const Default: Story = {
4641
name: "default",
@@ -64,9 +59,7 @@ export const Start: Story = {
6459

6560
export const Secondary: Story = {
6661
name: "secondary",
67-
args: {
68-
...examplesFromFixtures.find((f) => f.name === "secondary")?.options,
69-
},
62+
args: { ...examplesFromFixtures.find((f) => f.name === "secondary")?.options },
7063
};
7164

7265
export const Warning: Story = {
@@ -77,4 +70,4 @@ export const Warning: Story = {
7770
export const Inverse: Story = {
7871
name: "inverse",
7972
args: { ...examplesFromFixtures.find((f) => f.name === "inverse")?.options },
80-
};
73+
};

src/components/CharacterCount/CharacterCount.stories.tsx

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ let configured = false;
1515
const meta: Meta<typeof CharacterCount> = {
1616
title: "GOVUK Design System/Character count",
1717
component: CharacterCount,
18-
decorators: [
19-
(Story, { parameters }) => {
18+
decorators: [(Story, { parameters }) => {
2019
React.useEffect(() => {
21-
const isDocsMode = window.location.search.includes(
22-
"path=/docs/govuk-design-system-character-count--docs",
23-
);
20+
const isDocsMode = window.location.search.includes("path=/docs/govuk-design-system-character-count--docs");
2421
if (isDocsMode && !configured && parameters.initializeConfigurations) {
2522
ConfigureOverallCharacterCount();
2623
configured = true;
@@ -29,8 +26,7 @@ const meta: Meta<typeof CharacterCount> = {
2926
}
3027
}, []);
3128
return <Story />;
32-
},
33-
],
29+
}],
3430
tags: ["autodocs"],
3531
};
3632

@@ -39,8 +35,7 @@ type Story = StoryObj<typeof CharacterCount>;
3935

4036
// extractShownFixtures transforms raw govuk-frontend fixture data into
4137
// React-compatible props (e.g. text → children, classes → className).
42-
const examplesFromFixtures: Array<ComponentFixture> =
43-
extractShownFixtures(fixtures);
38+
const examplesFromFixtures: Array<ComponentFixture> = extractShownFixtures(fixtures);
4439

4540
export const Default: Story = {
4641
name: "default",
@@ -49,61 +44,40 @@ export const Default: Story = {
4944

5045
export const WithHint: Story = {
5146
name: "with hint",
52-
args: {
53-
...examplesFromFixtures.find((f) => f.name === "with hint")?.options,
54-
},
47+
args: { ...examplesFromFixtures.find((f) => f.name === "with hint")?.options },
5548
};
5649

5750
export const WithHintAndError: Story = {
5851
name: "with hint and error",
59-
args: {
60-
...examplesFromFixtures.find((f) => f.name === "with hint and error")
61-
?.options,
62-
},
52+
args: { ...examplesFromFixtures.find((f) => f.name === "with hint and error")?.options },
6353
};
6454

6555
export const WithDefaultValue: Story = {
6656
name: "with default value",
67-
args: {
68-
...examplesFromFixtures.find((f) => f.name === "with default value")
69-
?.options,
70-
},
57+
args: { ...examplesFromFixtures.find((f) => f.name === "with default value")?.options },
7158
};
7259

7360
export const WithDefaultValueExceedingLimit: Story = {
7461
name: "with default value exceeding limit",
75-
args: {
76-
...examplesFromFixtures.find(
77-
(f) => f.name === "with default value exceeding limit",
78-
)?.options,
79-
},
62+
args: { ...examplesFromFixtures.find((f) => f.name === "with default value exceeding limit")?.options },
8063
};
8164

8265
export const WithCustomRows: Story = {
8366
name: "with custom rows",
84-
args: {
85-
...examplesFromFixtures.find((f) => f.name === "with custom rows")?.options,
86-
},
67+
args: { ...examplesFromFixtures.find((f) => f.name === "with custom rows")?.options },
8768
};
8869

8970
export const WithLabelAsPageHeading: Story = {
9071
name: "with label as page heading",
91-
args: {
92-
...examplesFromFixtures.find((f) => f.name === "with label as page heading")
93-
?.options,
94-
},
72+
args: { ...examplesFromFixtures.find((f) => f.name === "with label as page heading")?.options },
9573
};
9674

9775
export const WithWordCount: Story = {
9876
name: "with word count",
99-
args: {
100-
...examplesFromFixtures.find((f) => f.name === "with word count")?.options,
101-
},
77+
args: { ...examplesFromFixtures.find((f) => f.name === "with word count")?.options },
10278
};
10379

10480
export const WithThreshold: Story = {
10581
name: "with threshold",
106-
args: {
107-
...examplesFromFixtures.find((f) => f.name === "with threshold")?.options,
108-
},
109-
};
82+
args: { ...examplesFromFixtures.find((f) => f.name === "with threshold")?.options },
83+
};

0 commit comments

Comments
 (0)