Skip to content

chore: update storybook up to 10v - #2666

Open
aeksandla wants to merge 17 commits into
mainfrom
chore/upgrade-storybook
Open

aeksandla wants to merge 17 commits into
mainfrom
chore/upgrade-storybook

Conversation

@aeksandla

@aeksandla aeksandla commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Upgrade Storybook tooling to v10 and update related configuration and theming to maintain compatibility.

Enhancements:

  • Adjust Storybook webpack configuration to inline CSS/SCSS handling and add an alias for the docs addon for compatibility with v10.
  • Update Storybook preview, theme, and custom theme addon to match the v10 API and use the package version from environment variables in the UI header.
  • Apply minor formatting and type-definition cleanups across components and stories without changing runtime behavior.

Build:

  • Bump Storybook core, addons, CLI, webpack5 integration, test runner, and eslint-plugin-storybook packages from v9.x to v10.3.x.

@sourcery-ai

sourcery-ai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Upgrades Storybook and related tooling to v10, reworks CSS/SCSS handling into a custom Webpack config, updates the custom theme addon and theme metadata sourcing to align with Storybook v10 APIs, adjusts preview/a11y/viewport configuration, and applies minor formatting/logic cleanups across components and stories.

File-Level Changes

Change Details Files
Migrate Storybook configuration and Webpack setup to v10 while preserving Sass support and docs behavior.
  • Switch sassFunctions import in main.ts to ESM-compatible path with .js extension.
  • Remove @storybook/addon-styling-webpack configuration and move CSS/SCSS loader chain (style-loader, css-loader, sass-loader with sassFunctions) into webpackFinal().
  • Ensure webpackConfig.resolve/module objects are initialized defensively and add alias mapping '@storybook/addon-docs$' to '@storybook/addon-docs/blocks'.
  • Update preview.tsx parameters to use backgrounds.disabled and viewport.options according to Storybook v10 API changes.
  • Adjust Accordion a11y addon configuration to use the context option instead of element.
.storybook/main.ts
.storybook/preview.tsx
.storybook/Accordion/__stories__/Accordion.stories.tsx
Update Storybook-related dependencies to 10.x and align eslint plugin versions.
  • Bump @storybook/* packages (addon-a11y, addon-docs, addon-webpack5-compiler-babel, cli, react-webpack5, test-runner) from ^9.x to ^10.3.6 (or matching latest).
  • Update eslint-plugin-storybook to ^10.3.6 to match Storybook v10.
  • Update storybook meta package to ^10.3.6.
  • Remove now-unused @storybook/addon-styling-webpack dependency.
package.json
package-lock.json
Adjust custom Storybook theme integration and theming metadata for the v10 manager API.
  • Change theme-addon/register.tsx to render the tool via React.createElement instead of JSX, which matches Storybook manager expectations.
  • Replace theme selection logic using getThemeType() with a simple light/dark switch based on DARK_THEMES set.
  • Change theme.ts to source the UIKit version from process.env.npm_package_version instead of importing package.json, avoiding CJS/ESM issues.
.storybook/theme-addon/register.tsx
.storybook/theme.ts
Apply minor TS/JS/SCSS formatting cleanups and logical condition simplifications to satisfy updated tooling/linters.
  • Reformat many interface extensions (extends Pick/Omit/Required) onto single lines or simplified multi-lines to comply with new lint/format rules without changing types.
  • Normalize SCSS selector indentation and parentheses in Button.scss and small condition formatting in Slider and UseSelectOptionsShowcase for readability and lint compliance.
  • Tighten some TypeScript interface declarations and component type aliases (e.g., Menu, RadioGroup, Palette, Box, TreeSelect, useList) without changing runtime behavior.
src/components/Button/Button.scss
src/components/Button/Button.tsx
src/components/TreeSelect/**
src/components/TreeList/**
src/components/tabs/types.ts
src/components/Accordion/AccordionContext.tsx
src/components/Drawer/components/Drawer.tsx
src/components/Palette/Palette.tsx
src/components/lab/FileDropZone/FileDropZone.Provider.tsx
src/components/lab/Menu/types.ts
src/components/NumberInput/NumberInput.tsx
src/components/useList/**
src/hooks/private/useRadioGroup/useRadioGroup.ts
src/components/ActionTooltip/ActionTooltip.tsx
src/components/Link/Link.tsx
src/components/Menu/Menu.tsx
src/components/Modal/Modal.tsx
src/components/Popup/Popup.tsx
src/components/RadioGroup/RadioGroup.tsx
src/components/SegmentedRadioGroup/**
src/components/Text/Text.tsx
src/components/Tooltip/Tooltip.tsx
src/components/DefinitionList/components/DefinitionListContext.tsx
src/components/Progress/types.ts
src/components/Disclosure/DisclosureContext.tsx
src/components/Slider/Slider.tsx
src/components/Skeleton/Skeleton.tsx
src/components/layout/Box/Box.tsx
src/components/legacy/Tabs/Tabs.tsx

Possibly linked issues

  • #: PR directly fulfills the issue by upgrading Storybook and its addons to v10 and updating related configs.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui

gravity-ui Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui

gravity-ui Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new global Webpack rule for /\.(css|scss)$/ in .storybook/main.ts will also process styles from node_modules; consider adding an include (e.g. your source directory) or exclude: /node_modules/ to avoid unexpected loader interactions and build slowdowns.
  • The theme addon now infers dark mode via a hardcoded DARK_THEMES set instead of getThemeType; double-check that all existing and future theme values (including any brand or HC variants) are still mapped correctly to light/dark manager themes to avoid regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new global Webpack rule for `/\.(css|scss)$/` in `.storybook/main.ts` will also process styles from `node_modules`; consider adding an `include` (e.g. your source directory) or `exclude: /node_modules/` to avoid unexpected loader interactions and build slowdowns.
- The theme addon now infers dark mode via a hardcoded `DARK_THEMES` set instead of `getThemeType`; double-check that all existing and future theme values (including any brand or HC variants) are still mapped correctly to light/dark manager themes to avoid regressions.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .storybook/preview.tsx Outdated
},
jsx: {showFunctions: true}, // To show functions in sources
backgrounds: {disable: true},
backgrounds: {disabled: true},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not working:

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

'qa' | 'className' | 'value' | 'defaultValue' | 'multiple' | 'ariaLabel'
>
> {
interface AccordionProviderProps<Multiple extends boolean> extends Required<

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why formating changed? New Prettier version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes
The new version of @storybook/cli has a dependency with version prettier@3.8.3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove cli dependency. We dont use it anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread .storybook/theme-addon/register.tsx Outdated
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
api.setOptions({theme: themes[DARK_THEMES.has(theme) ? 'dark' : 'light']});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with the getThemeType utility?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and returned it as it was. Everything is working

Comment thread .storybook/main.ts Outdated
webpackConfig.resolve = webpackConfig.resolve ?? {};
webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias ?? {}),
'@storybook/addon-docs$': '@storybook/addon-docs/blocks',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we add this alias if we use normal path anyway ('@storybook/addon-docs/blocks)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not everywhere. I replaced all the imports and removed this alias.

Comment thread .storybook/main.ts Outdated
};

webpackConfig.module = webpackConfig.module ?? {rules: []};
webpackConfig.module.rules = webpackConfig.module.rules ?? [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need these fallbacks for config properties?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because webpackConfig.module.rules is possibly undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it's different from what's the @storybook/addon-styling-webpack is doing?

@aeksandla
aeksandla requested a review from amje June 4, 2026 08:43
Comment thread .storybook/theme-addon/register.tsx Outdated
title: 'Theme',
render: () => {
return <Tool api={api} />;
return React.createElement(Tool, {api});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced JSX with React.createElement because Storybook 10 loads the preset without TSX-loader.

Comment thread .storybook/main.ts Outdated
};

webpackConfig.module = webpackConfig.module ?? {rules: []};
webpackConfig.module.rules = webpackConfig.module.rules ?? [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it's different from what's the @storybook/addon-styling-webpack is doing?

Comment thread .storybook/preview.tsx
},
},
globalTypes: {
theme: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's capitalize the parameter names in the toolbar, Storybook now shows a tooltip with that name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread package.json Outdated
"npm-run-all": "^4.1.5",
"postcss": "^8.5.6",
"prettier": "^3.5.3",
"prettier": "3.5.3",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's fixed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returned it as it was

# Conflicts:
#	package-lock.json
#	src/components/layout/LayoutProvider/__stories__/Layout.mdx
#	src/stories/Branding/Overview.mdx
@aeksandla
aeksandla requested a review from amje August 24, 2026 08:10
# Conflicts:
#	package-lock.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants