-
Notifications
You must be signed in to change notification settings - Fork 87
feat(storybook): upgrade to v10 #7368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,20 @@ | ||
| import { StorybookConfig } from "@storybook/react-vite"; | ||
| // This file has been automatically migrated to valid ESM format by Storybook. | ||
| import { fileURLToPath } from "node:url"; | ||
| import type { StorybookConfig } from "@storybook/react-vite"; | ||
| import type { UserConfig } from "vite"; | ||
|
|
||
| import react from "@vitejs/plugin-react"; | ||
| import { viteStaticCopy } from "vite-plugin-static-copy"; | ||
|
|
||
| import path from "path"; | ||
| import path, { dirname } from "path"; | ||
|
|
||
| import glob from "glob"; | ||
|
|
||
| import remarkGfm from "remark-gfm"; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const projectRoot = path.resolve(__dirname, "../"); | ||
| const ignoreTests = process.env.IGNORE_TESTS === "true"; | ||
| const enableReactStrictMode = process.env.ENABLE_REACT_STRICT_MODE === "true"; | ||
|
|
@@ -45,8 +51,6 @@ const config: StorybookConfig = { | |
|
|
||
| addons: [ | ||
| "@storybook/addon-a11y", | ||
| "@storybook/addon-actions", | ||
| "@storybook/addon-controls", | ||
| { | ||
| name: "@storybook/addon-docs", | ||
| options: { | ||
|
|
@@ -57,22 +61,20 @@ const config: StorybookConfig = { | |
| }, | ||
| }, | ||
| }, | ||
| "@storybook/addon-interactions", | ||
| "storybook-addon-pseudo-states", | ||
| "@storybook/addon-essentials", | ||
| "@storybook/addon-toolbars", | ||
| "@storybook/addon-viewport", | ||
| "@chromatic-com/storybook", | ||
| ], | ||
|
|
||
| staticDirs: ["../.assets", "../logo"], | ||
|
|
||
| viteFinal: async (config) => { | ||
| viteFinal: async (config: UserConfig) => { | ||
| const { mergeConfig } = await import("vite"); | ||
|
|
||
| return mergeConfig(config, { | ||
| plugins: [ | ||
| react(), | ||
| react({ | ||
| exclude: [/\.storybook\//], | ||
| }), | ||
| viteStaticCopy({ | ||
| targets: [ | ||
| { | ||
|
|
@@ -111,12 +113,12 @@ const config: StorybookConfig = { | |
| }, | ||
|
|
||
| ...(isChromatic && { | ||
| previewHead: (head) => ` | ||
| ${head} | ||
| previewHead: (head: string | undefined) => ` | ||
| ${head || ""} | ||
| <meta name="robots" content="noindex"> | ||
| `, | ||
| managerHead: (head) => ` | ||
| ${head} | ||
| managerHead: (head: string | undefined) => ` | ||
| ${head || ""} | ||
| <meta name="robots" content="noindex"> | ||
| `, | ||
| }), | ||
|
|
@@ -127,7 +129,28 @@ const config: StorybookConfig = { | |
| // Exclude legacy Switch component from react-docgen as it's intended to be removed | ||
| // in a future release and causes confusion for Storybook generating docs. | ||
| reactDocgenTypescriptOptions: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: when running storybook locally we're met with quite a few Vite warnings for docgen skipping Could we do some sort of exclusion in here to avoid this? |
||
| exclude: ["**/switch/switch.component.tsx"], | ||
| exclude: ["**/switch/switch.component.tsx", "**/.storybook/**"], | ||
| shouldExtractLiteralValuesFromEnum: true, | ||
| shouldRemoveUndefinedFromOptional: true, | ||
| shouldIncludePropTagMap: true, | ||
| propFilter: (prop) => { | ||
| const parentFile = prop.parent?.fileName; | ||
|
|
||
| if (!parentFile) { | ||
| return true; | ||
| } | ||
|
|
||
| if (parentFile.includes(".storybook")) { | ||
| return false; | ||
| } | ||
|
|
||
| // Prevent inherited DOM and third-party utility types from flooding docs tables. | ||
| if (parentFile.includes("/node_modules/")) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,76 @@ | |
| <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" /> | ||
| <meta name="msapplication-TileColor" content="#da532c" /> | ||
| <meta name="theme-color" content="#ffffff" /> | ||
|
|
||
| <style> | ||
| #storybook-explorer-toolbar, | ||
| [role="toolbar"], | ||
| [role="region"][data-testid="sb-preview-toolbar"] { | ||
| background-color: #000000 !important; | ||
| background: #000000 !important; | ||
| box-shadow: black 0px -1px 0px 0px inset !important; | ||
| } | ||
|
|
||
| #storybook-explorer-toolbar *, | ||
| [role="toolbar"] * { | ||
| color: #FFFFFF !important; | ||
| } | ||
|
|
||
| #storybook-explorer-toolbar button, | ||
| #storybook-explorer-toolbar svg, | ||
| [role="toolbar"] button, | ||
| [role="toolbar"] svg { | ||
| color: #FFFFFF !important; | ||
| fill: #FFFFFF !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button, | ||
| [role="toolbar"] button *, | ||
| [role="toolbar"] div { | ||
| background-color: transparent !important; | ||
| background: transparent !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button:hover, | ||
| [role="toolbar"] button * { | ||
| color: #FFFFFF !important; | ||
| fill: #FFFFFF !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button:hover, | ||
| [role="toolbar"] button:hover * { | ||
| color: #00DC00 !important; | ||
| fill: #00DC00 !important; | ||
| opacity: 0.8 !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button[aria-label*="Locale"], | ||
| [role="toolbar"] button[aria-label*="Colour Mode"], | ||
| [role="toolbar"] button[aria-label*="Theme"], | ||
| [role="toolbar"] button[aria-label*="locale"], | ||
| [role="toolbar"] button[aria-label*="mode"], | ||
| [role="toolbar"] button[aria-label*="theme"], | ||
| [role="toolbar"] button[aria-label*="Locale"] *, | ||
| [role="toolbar"] button[aria-label*="Colour Mode"] *, | ||
| [role="toolbar"] button[aria-label*="Theme"] *, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (non-blocking): would |
||
| [role="toolbar"] button[aria-label*="locale"] *, | ||
| [role="toolbar"] button[aria-label*="mode"] *, | ||
| [role="toolbar"] button[aria-label*="theme"] * { | ||
| color: #00DC00 !important; | ||
| fill: #00DC00 !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button[title*="version"] *, | ||
| [role="toolbar"] button[aria-label*="interaction"] * { | ||
| color: #00DC00 !important; | ||
| fill: #00DC00 !important; | ||
| } | ||
|
|
||
| [role="toolbar"] button[title*="version"], | ||
| [role="toolbar"] button[aria-label*="interaction"] { | ||
| color: #00DC00 !important; | ||
| fill: #00DC00 !important; | ||
| box-shadow: #00DC00 0px 0px 0px 1px inset !important; | ||
| } | ||
|
|
||
| </style> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addons list drops
@storybook/addon-actions,@storybook/addon-controls, and@storybook/addon-viewport/@storybook/addon-essentials, but the codebase still usesaction(...)across many*-test.stories.tsxand relies on controls/viewport parameters inpreview.ts. Unless Storybook v10 is configured elsewhere to include these capabilities, this will remove expected UI panels/behavior. Re-add@storybook/addon-essentials(or the specific addons you need) to keep actions/controls/viewport working.