Skip to content

Commit 352208d

Browse files
committed
feat(storybook): upgrade to v9
- change the way we hide stories to the documented method as per Storybook docs
1 parent cbf9cfd commit 352208d

File tree

317 files changed

+698
-1576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

317 files changed

+698
-1576
lines changed

.storybook/main.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ const config: StorybookConfig = {
4040

4141
addons: [
4242
"@storybook/addon-a11y",
43-
"@storybook/addon-actions",
44-
"@storybook/addon-controls",
4543
{
4644
name: "@storybook/addon-docs",
4745
options: {
@@ -52,11 +50,7 @@ const config: StorybookConfig = {
5250
},
5351
},
5452
},
55-
"@storybook/addon-interactions",
5653
"storybook-addon-pseudo-states",
57-
"@storybook/addon-essentials",
58-
"@storybook/addon-toolbars",
59-
"@storybook/addon-viewport",
6054
"@chromatic-com/storybook",
6155
],
6256

.storybook/manager.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { addons, types } from "@storybook/manager-api";
1+
import { addons, types } from "storybook/manager-api";
22
import sageTheme from "./sage-docs-theme";
33
import { ADDON_ID, TOOL_ID } from "./version-picker/constants";
44
import { VersionPicker } from "./version-picker";
5-
import { API_PreparedIndexEntry, API_StatusObject } from "@storybook/types";
5+
import { API_PreparedIndexEntry } from "storybook/internal/types";
66

77
const useVersionPicker = process.env.USE_VERSION_PICKER === "true";
88

@@ -20,15 +20,4 @@ if (useVersionPicker) {
2020
addons.setConfig({
2121
theme: sageTheme,
2222
panelPosition: "bottom",
23-
sidebar: {
24-
filters: {
25-
patterns: (
26-
item: API_PreparedIndexEntry & {
27-
status: Record<string, API_StatusObject | null>;
28-
},
29-
): boolean => {
30-
return !(item.tags ?? []).includes("hideInSidebar");
31-
},
32-
},
33-
},
3423
});

.storybook/preview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Preview } from "@storybook/react";
2-
import { configure } from "@storybook/test";
1+
import { Preview } from "@storybook/react-vite";
2+
import { configure } from "storybook/test";
33

44
import "../src/style/fonts.css";
55

.storybook/sage-docs-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { create } from "@storybook/theming/create";
1+
import { create } from "storybook/theming/create";
22

33
export default create({
44
base: "light",

.storybook/sage-storybook-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { create } from "@storybook/theming/create";
1+
import { create } from "storybook/theming/create";
22

33
export default create({
44
base: "light",

.storybook/utils/partial-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { action } from "@storybook/addon-actions";
1+
import { action } from "storybook/actions";
22
import React from "react";
33

44
function partialAction(actionName: string) {
@@ -7,7 +7,7 @@ function partialAction(actionName: string) {
77
typeof eventObj === "string"
88
? { view: undefined }
99
: { ...eventObj, view: undefined },
10-
...args
10+
...args,
1111
);
1212
};
1313
}

.storybook/utils/styled-system-props.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArgTypes } from "@storybook/react";
1+
import { ArgTypes } from "@storybook/react-vite";
22
import {
33
SpaceProps,
44
LayoutProps,
@@ -77,7 +77,7 @@ type Props = {
7777
};
7878

7979
const generateStyledSystemMarginProps = (
80-
defaults: StyledSystemDefaults
80+
defaults: StyledSystemDefaults,
8181
): ArgTypes[] => {
8282
return [
8383
{
@@ -843,7 +843,7 @@ const generateStyledSystemGridProps = (defaults: StyledSystemDefaults) => {
843843
};
844844

845845
const generateStyledSystemBackgroundProps = (
846-
defaults: StyledSystemDefaults
846+
defaults: StyledSystemDefaults,
847847
) => {
848848
return [
849849
{
@@ -994,13 +994,13 @@ const generateStyledSystemPositionProps = (defaults: StyledSystemDefaults) => {
994994

995995
const filterProps = (
996996
props: Record<string, unknown>[],
997-
excludes: string[] = []
997+
excludes: string[] = [],
998998
) => props.filter((prop) => !excludes.includes(Object.keys(prop)[0]));
999999

10001000
const generateStyledSystemProps = (
10011001
props: StyledSystemProps,
10021002
defaults?: StyledSystemDefaults,
1003-
excludes?: string[]
1003+
excludes?: string[],
10041004
): ArgTypes<StyledSystemProps> => {
10051005
const {
10061006
spacing,
@@ -1019,67 +1019,76 @@ const generateStyledSystemProps = (
10191019
if (spacing) {
10201020
Object.assign(
10211021
result,
1022-
...filterProps(generateStyledSystemSpacingProps(defaults || {}), excludes)
1022+
...filterProps(
1023+
generateStyledSystemSpacingProps(defaults || {}),
1024+
excludes,
1025+
),
10231026
);
10241027
}
10251028
if (margin) {
10261029
Object.assign(
10271030
result,
1028-
...filterProps(generateStyledSystemMarginProps(defaults || {}), excludes)
1031+
...filterProps(generateStyledSystemMarginProps(defaults || {}), excludes),
10291032
);
10301033
}
10311034
if (padding) {
10321035
Object.assign(
10331036
result,
1034-
...filterProps(generateStyledSystemPaddingProps(defaults || {}), excludes)
1037+
...filterProps(
1038+
generateStyledSystemPaddingProps(defaults || {}),
1039+
excludes,
1040+
),
10351041
);
10361042
}
10371043
if (color) {
10381044
Object.assign(
10391045
result,
1040-
...filterProps(generateStyledSystemColorProps(defaults || {}), excludes)
1046+
...filterProps(generateStyledSystemColorProps(defaults || {}), excludes),
10411047
);
10421048
}
10431049
if (layout) {
10441050
Object.assign(
10451051
result,
1046-
...filterProps(generateStyledSystemLayoutProps(defaults || {}), excludes)
1052+
...filterProps(generateStyledSystemLayoutProps(defaults || {}), excludes),
10471053
);
10481054
}
10491055
if (width) {
10501056
Object.assign(
10511057
result,
1052-
...filterProps(generateStyledSystemWidthProps(defaults || {}), excludes)
1058+
...filterProps(generateStyledSystemWidthProps(defaults || {}), excludes),
10531059
);
10541060
}
10551061
if (flexBox) {
10561062
Object.assign(
10571063
result,
1058-
...filterProps(generateStyledSystemFlexBoxProps(defaults || {}), excludes)
1064+
...filterProps(
1065+
generateStyledSystemFlexBoxProps(defaults || {}),
1066+
excludes,
1067+
),
10591068
);
10601069
}
10611070
if (grid) {
10621071
Object.assign(
10631072
result,
1064-
...filterProps(generateStyledSystemGridProps(defaults || {}), excludes)
1073+
...filterProps(generateStyledSystemGridProps(defaults || {}), excludes),
10651074
);
10661075
}
10671076
if (background) {
10681077
Object.assign(
10691078
result,
10701079
...filterProps(
10711080
generateStyledSystemBackgroundProps(defaults || {}),
1072-
excludes
1073-
)
1081+
excludes,
1082+
),
10741083
);
10751084
}
10761085
if (position) {
10771086
Object.assign(
10781087
result,
10791088
...filterProps(
10801089
generateStyledSystemPositionProps(defaults || {}),
1081-
excludes
1082-
)
1090+
excludes,
1091+
),
10831092
);
10841093
}
10851094

.storybook/version-picker/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import {
44
WithTooltip,
55
TooltipLinkList,
66
TooltipLinkListLink,
7-
} from "@storybook/components";
7+
} from "storybook/internal/components";
88
import compareBuild from "semver/functions/compare-build";
99

1010
import { TOOL_ID } from "./constants";
1111
import fetchData from "./fetch-data";
1212

1313
const getDisplayedItems = (
1414
versions: Record<string, string>,
15-
onClick: TooltipLinkListLink["onClick"]
15+
onClick: TooltipLinkListLink["onClick"],
1616
) => {
1717
let formattedVersions: TooltipLinkListLink[] = [];
1818

@@ -36,7 +36,7 @@ const getDisplayedItems = (
3636

3737
export const VersionPicker = () => {
3838
const [versions, setVersions] = useState<Record<string, string> | undefined>(
39-
undefined
39+
undefined,
4040
);
4141
const [currentVersion, setCurrentVersion] = useState("Latest");
4242

.storybook/with-global-styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Decorator } from "@storybook/react";
1+
import { Decorator } from "@storybook/react-vite";
22
import React from "react";
33
import GlobalStyle from "../src/style/global-style";
44

.storybook/with-locale-selector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from "react";
2-
import { Decorator } from "@storybook/react";
2+
import { Decorator } from "@storybook/react-vite";
33
import I18nProvider from "../src/components/i18n-provider";
44
import { enGB, deDE, enCA, enUS, esES, frCA, frFR } from "../src/locales";
55

66
const withLocaleSelector: Decorator = (Story, context) => {
77
const selectedLocale =
88
[enGB, deDE, enCA, enUS, esES, frCA, frFR].find(
9-
({ locale }) => locale?.() === context.globals.locale
9+
({ locale }) => locale?.() === context.globals.locale,
1010
) || enGB;
1111

1212
return (

0 commit comments

Comments
 (0)