Skip to content

Conversation

lifeiscontent
Copy link
Collaborator

@lifeiscontent lifeiscontent commented Jun 4, 2025

Description

Upgrade storybook to v9 in ui package

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features
    • Updated Storybook integration to the latest major version with improved configuration and addon management.
  • Refactor
    • Simplified and improved type safety in Storybook stories for multiple UI components.
    • Centralized and streamlined story definitions by moving shared arguments and leveraging stronger TypeScript inference.
  • Chores
    • Upgraded and cleaned up Storybook-related dependencies.
    • Enhanced linting rules for Storybook usage.

@CLAassistant
Copy link

CLAassistant commented Jun 4, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

Walkthrough

This update upgrades Storybook and related dependencies from version 8.x to 9.x in the packages/ui package, refactors Storybook configuration and stories for compatibility, and enhances type safety and code consistency. It also adjusts ESLint settings to include Storybook recommendations and updates CSS handling in the Storybook Webpack configuration.

Changes

File(s) Change Summary
packages/ui/.eslintrc.js Extended ESLint configuration to include "plugin:storybook/recommended" for Storybook-specific linting rules.
packages/ui/.storybook/main.ts Updated Storybook addons: removed onboarding, essentials, interactions, and styling-webpack; added docs addon. Introduced an async webpackFinal function to customize CSS loader configuration.
packages/ui/.storybook/preview.ts Changed CSS import from output.css to globals.css; updated Storybook type import to @storybook/react-webpack5.
packages/ui/package.json Upgraded Storybook and related dependencies to 9.x; removed deprecated addons; added new dependencies for docs and linting; updated Chromatic and SWC compiler versions; added postcss-loader.
packages/ui/src/avatar/avatar.stories.tsx Updated Storybook type imports; centralized default name arg in meta; simplified story args for Default and Large stories.
packages/ui/src/popovers/popover-menu.stories.tsx Refactored to use @storybook/react-webpack5 types; inlined render logic; moved args to meta; simplified type annotations; exported meta as default.
packages/ui/src/popovers/popover.stories.tsx Switched to @storybook/react-webpack5 import; inlined custom popover component; consolidated args to meta; simplified stories; exported meta as default.
packages/ui/src/sortable/sortable.stories.tsx Updated to use @storybook/react-webpack5 types; improved typing for data; moved onChange to argTypes with action; exported meta as default; simplified story definition.
packages/ui/src/tables/table.stories.tsx Changed to @storybook/react-webpack5 imports; removed explicit row data type; used satisfies for column typing; improved type inference; exported meta as default; simplified story definition.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant StorybookConfig
    participant Webpack
    participant Linting

    Developer->>StorybookConfig: Runs Storybook (v9)
    StorybookConfig->>Webpack: Apply async webpackFinal (custom CSS loaders)
    StorybookConfig->>Linting: Use ESLint with Storybook recommended rules
    StorybookConfig->>StorybookConfig: Load updated addons (docs, etc.)
    StorybookConfig->>Developer: Serve updated Storybook UI with new stories and config
Loading

Suggested labels

🌟improvement, 🌐frontend

Poem

🐇✨
Up hopped the rabbit with a Storybook tale,
Upgrades and configs set forth to prevail.
Types are inferred, the linting is neat,
Addons refreshed for a frontend treat.
CSS now flows with loaders anew,
Hooray for the stories—bright, shiny, and true!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

makeplane bot commented Jun 4, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Storybook configuration and related story files in the ui package to support Storybook v9 with webpack5 and refactors story definitions for improved type usage. Key changes include:

  • Updating imports from "@storybook/react" to "@storybook/react-webpack5" across story files.
  • Refactoring story meta definitions and type annotations to leverage modern TypeScript features.
  • Upgrading related dependencies in package.json and adjusting ESLint and Webpack configurations.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/ui/src/tables/table.stories.tsx Refactored story meta and type definitions for the Table component.
packages/ui/src/sortable/sortable.stories.tsx Updated meta signature and inline type usage for the Sortable component story.
packages/ui/src/popovers/popover.stories.tsx Simplified Popover story by inlining custom component rendering.
packages/ui/src/popovers/popover-menu.stories.tsx Inlined render logic and updated meta configuration for PopoverMenu.
packages/ui/src/avatar/avatar.stories.tsx Adapted story meta and default story for the Avatar component.
packages/ui/package.json Upgraded Storybook and related dependencies to v9 versions.
packages/ui/.storybook/preview.ts Updated global CSS import and Storybook type import for webpack5.
packages/ui/.storybook/main.ts Added webpackFinal to modify CSS rules for compatibility with the new Storybook version.
packages/ui/.eslintrc.js Extended ESLint config to include Storybook recommended plugin.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1113f9f and d10a1ba.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • packages/ui/.eslintrc.js (1 hunks)
  • packages/ui/.storybook/main.ts (1 hunks)
  • packages/ui/.storybook/preview.ts (1 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/ui/src/avatar/avatar.stories.tsx (1 hunks)
  • packages/ui/src/popovers/popover-menu.stories.tsx (1 hunks)
  • packages/ui/src/popovers/popover.stories.tsx (1 hunks)
  • packages/ui/src/sortable/sortable.stories.tsx (1 hunks)
  • packages/ui/src/tables/table.stories.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (21)
packages/ui/.storybook/preview.ts (1)

1-2: LGTM! Imports correctly updated for Storybook v9.

The changes properly reflect the migration to Storybook v9 with webpack5 and the CSS restructuring from processed output to global styles.

packages/ui/.eslintrc.js (1)

4-4: LGTM! Proper integration of Storybook ESLint rules.

Adding the Storybook recommended configuration is a best practice that will help catch Storybook-specific issues and maintain consistency.

packages/ui/package.json (1)

50-69:

❓ Verification inconclusive

Verify dependency compatibility and completeness.

The Storybook v9 upgrade looks comprehensive, but please verify:

  1. All removed Storybook v8 dependencies are properly cleaned up
  2. The new postcss-loader version (8.1.1) is compatible with the webpack configuration
  3. Version compatibility between all Storybook v9 packages

🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining v8 Storybook dependencies and verify package compatibility

# Check for any remaining v8 storybook packages
echo "Checking for remaining v8 Storybook packages:"
jq -r '.devDependencies | to_entries[] | select(.key | contains("storybook")) | "\(.key): \(.value)"' packages/ui/package.json

# Check if postcss-loader is used elsewhere in the monorepo
echo -e "\nChecking postcss-loader usage across monorepo:"
fd "package.json" --exec jq -r 'select(.devDependencies."postcss-loader" or .dependencies."postcss-loader") | "postcss-loader found in: " + input_filename' 2>/dev/null || echo "No other postcss-loader dependencies found"

Length of output: 770


Dependency cleanup complete, pending manual compatibility checks

All Storybook v8 packages have been removed from packages/ui/package.json—only v9 add-ons remain—and [email protected] is only declared in that package. Before merging:

  • Confirm that [email protected] integrates correctly with your Webpack setup.
  • Run Storybook locally (and in CI) to validate compatibility across all v9 add-ons.
  • Double-check no other packages in the monorepo still reference v8 Storybook or postcss-loader.
packages/ui/src/avatar/avatar.stories.tsx (3)

1-1: LGTM! Correct import for Storybook v9 webpack5.

The import change aligns with the migration to Storybook v9 and webpack5.


7-9: LGTM! Good practice centralizing common args.

Moving shared arguments to the meta level reduces duplication and follows Storybook v9 best practices.


16-22: LGTM! Clean story definitions with proper inheritance.

The simplified story exports properly inherit the common args from meta while allowing individual stories to override specific properties.

packages/ui/.storybook/main.ts (1)

18-18: LGTM! Proper addition of docs addon.

Adding @storybook/addon-docs is appropriate for the v9 upgrade and provides enhanced documentation capabilities.

packages/ui/src/popovers/popover.stories.tsx (3)

1-1: LGTM: Correct Storybook v9 import update

The import change from @storybook/react to @storybook/react-webpack5 is correct for the Storybook v9 upgrade.


11-25: Good refactor: Inlined children prop improves readability

The inlining of the JSX content directly into the children prop eliminates an unnecessary intermediate constant and makes the story definition cleaner.


29-33: LGTM: Proper story structure for Storybook v9

The changes correctly implement the modern Storybook pattern:

  • Meta exported as default at the bottom
  • Story type using typeof meta for better type inference
  • Default story simplified to rely on meta-level args
packages/ui/src/sortable/sortable.stories.tsx (4)

1-1: LGTM: Correct Storybook v9 import update

The import change to @storybook/react-webpack5 is correct for the upgrade.


13-13: Excellent type safety improvement

The meta type Meta<typeof Sortable<(typeof data)[number]>> provides better type inference by deriving the generic type from the data array elements.


18-24: Good simplification: Type inference over explicit annotations

Removing explicit type annotations on render and keyExtractor functions is appropriate since TypeScript can infer these types from the context.


25-29: Good addition: Action logging for onChange

Adding onChange to argTypes with action logging enables Storybook's action panel to show when the callback is triggered, which is helpful for testing and documentation.

packages/ui/src/popovers/popover-menu.stories.tsx (3)

1-1: LGTM: Consistent import update for Storybook v9

Correctly updated to @storybook/react-webpack5 consistent with the other story files.


12-12: Good type safety improvement

The meta type using Meta<typeof PopoverMenu<(typeof data)[number]>> provides better type inference similar to the other upgraded stories.


19-24: Clean refactor: Inlined render function

The render function is now defined inline within the args, eliminating the need for a separate constant and making the story more self-contained.

packages/ui/src/tables/table.stories.tsx (4)

1-4: LGTM: Correct imports for Storybook v9 upgrade

The import updates are consistent with the Storybook v9 upgrade, including the addition of TTableColumn type import.


17-28: Good type inference: Removed redundant annotations

Removing explicit type annotations from tdRender parameters is appropriate since TypeScript can infer the rowData type from the table's generic type.


29-29: Excellent use of satisfies operator

The satisfies TTableColumn<typeof tableData[number]>[] ensures type safety for the columns array while preserving the inferred types of individual elements. This is a modern TypeScript best practice.


31-52: LGTM: Consistent story structure upgrade

The meta type definition and story structure follow the same improved pattern as the other upgraded story files, providing better type safety and cleaner code organization.

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