Skip to content
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

chore: upgrade storybook 8 #4124

Draft
wants to merge 1 commit into
base: canary
Choose a base branch
from
Draft

Conversation

winchesHe
Copy link
Member

@winchesHe winchesHe commented Nov 20, 2024

📝 Description

Currently, there are many issues and incorrect usages with version 7 of Storybook.

Some typical problems include:

  1. HMR invalidate Could not Fast Refresh, reducing development efficiency.
  2. Errors on the homepage in development mode.
  3. Outdated configuration file definitions.

Google Chrome 2024-11-20 22 04 09

image

To resolve the issues mentioned above we have upgraded to the latest Storybook 8.

The main changes include:

  1. Resolved the fast refresh issue for components, leading to an improved development experience.
  2. Changed the configuration file from main.js to main.ts for better type hinting.
  3. Renamed xxx.storybook.mdx to xxx.mdx.
  4. Added the autodocs addon.
  5. Fixed errors on the homepage.

Summary by CodeRabbit

  • New Features

    • Upgraded Storybook to version 8.4.4, introducing new features and improvements.
    • Added support for remark-gfm to enhance documentation capabilities.
  • Bug Fixes

    • Improved logic for determining strict mode in Storybook.
  • Documentation

    • Updated paths and configurations in Storybook documentation files for clarity and consistency.
  • Chores

    • Cleaned up and standardized code formatting across various files.

Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 1:55pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 1:55pm

Copy link

changeset-bot bot commented Nov 20, 2024

⚠️ No Changeset found

Latest commit: 72db05e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

Walkthrough

This pull request introduces several updates primarily focused on upgrading the @storybook packages in the package.json files, enhancing the Storybook configuration, and modifying the StrictModeDecorator function in the Storybook addon. The main changes include transitioning to ES module syntax in the configuration, updating the content paths, and ensuring consistency in code formatting across files. Additionally, the welcome.mdx file has been slightly modified for structural consistency, while the Tailwind CSS configuration reflects a corrected content path.

Changes

File Path Change Summary
packages/storybook/package.json Updated @storybook dependencies from ^7.4.6 to ^8.4.4, added remark-gfm as a new dependency.
packages/storybook/.storybook/addons/react-strict-mode/index.tsx Reformatted imports, updated logic in StrictModeDecorator, and ensured consistent semicolon usage.
packages/storybook/.storybook/main.ts Converted to ES module syntax, updated stories path, modified addons configuration, and added type safety.
packages/storybook/.storybook/welcome.mdx Replaced <p> with <div> and adjusted <time> attribute for JSX compliance.
packages/storybook/tailwind.config.js Updated content path from ./.storybook/welcome.stories.mdx to ./.storybook/welcome.mdx.

Possibly related PRs

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • jrgarciadev
  • wingkwong

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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
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

🧹 Outside diff range and nitpick comments (5)
packages/storybook/.storybook/addons/react-strict-mode/index.tsx (1)

7-8: Consider more robust boolean parsing

The direct string comparison === "true" could be made more robust to handle various truthy values.

-  const [isStrict, setStrict] = useState(strictQuery === "true");
+  const [isStrict, setStrict] = useState(strictQuery?.toLowerCase() === "true");
packages/storybook/.storybook/main.ts (3)

19-28: Consider adding configuration documentation

The new @storybook/addon-docs configuration with remarkGfm is well-structured, but it would be helpful to add a comment explaining the purpose of these specific options and why remarkGfm is needed.

+    // Enable GitHub Flavored Markdown support in documentation
     {
       name: '@storybook/addon-docs',
       options: {

33-35: Consider removing empty options object

If there are no specific framework options needed, you could remove the empty options object to keep the configuration concise.


45-47: Consider documentation strategy with autodocs

Enabling autodocs: true will automatically generate documentation for all stories. This can significantly increase the documentation surface area. Consider:

  1. The impact on build time and bundle size
  2. Whether all components should have auto-generated docs
  3. Setting up documentation standards for consistency
packages/storybook/.storybook/welcome.mdx (1)

16-18: Consider semantic HTML structure

While the change from <p> to <div> works, consider keeping the <p> tag for better semantic meaning since this is a paragraph of text. The styling can still be achieved with the same Tailwind classes.

-<div className="!text-base !text-foreground max-w-xl [&>p]:text-foreground [&>p]:text-base">
+<p className="!text-base !text-foreground max-w-xl">
   Here you can find the guidelines, components APIs and examples to help you build your next project with NextUI.
-</div>
+</p>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ce1546c and 72db05e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • packages/storybook/.storybook/addons/react-strict-mode/index.tsx (1 hunks)
  • packages/storybook/.storybook/main.ts (1 hunks)
  • packages/storybook/.storybook/welcome.mdx (2 hunks)
  • packages/storybook/package.json (1 hunks)
  • packages/storybook/tailwind.config.js (1 hunks)
🔇 Additional comments (12)
packages/storybook/.storybook/addons/react-strict-mode/index.tsx (3)

1-4: LGTM! Clean and well-organized imports

The imports are properly structured with specific named imports and appropriate type imports.


10-18: LGTM! Clean effect implementation

The effect properly sets up and cleans up the channel subscription.


22-29: LGTM! Well-structured decorator implementation

The decorator follows Storybook's best practices for decorator implementation.

packages/storybook/.storybook/main.ts (3)

2-5: LGTM! Good type safety improvements

The addition of proper TypeScript types and necessary imports enhances code reliability and maintainability.


6-10: Verify the welcome.mdx file path

The path has been updated from welcome.stories.mdx to welcome.mdx. Please ensure that this file exists at the new location and that all story paths are correctly configured.


54-54: LGTM! Good modernization

The switch to ES module syntax with export default aligns with modern JavaScript practices.

packages/storybook/package.json (3)

40-50: Major version upgrade requires migration steps

This is a major version upgrade from Storybook 7 to 8, which likely includes breaking changes. Please document the migration steps and any breaking changes that NextUI users need to be aware of.

Consider:

  • Adding migration notes to the PR description
  • Documenting any breaking changes
  • Testing all existing stories for compatibility

52-53: Verify dark mode compatibility

The upgrade of storybook-dark-mode from 3.x to 4.x may require changes to the dark mode configuration. Please ensure that the dark mode functionality continues to work as expected.


54-54: Document the purpose of remark-gfm

The addition of remark-gfm suggests enhanced markdown support. This is likely required for MDX documentation in Storybook 8, but it would be helpful to document why this dependency was added.

packages/storybook/tailwind.config.js (1)

6-6: LGTM! Please verify the welcome.mdx file path.

The path update aligns with Storybook v8 conventions by simplifying the extension from .stories.mdx to .mdx. Please ensure that the file exists at ./.storybook/welcome.mdx to prevent any build failures.

packages/storybook/.storybook/welcome.mdx (1)

129-130: LGTM! JSX compliance improvement

Good update to change datetime to dateTime for proper JSX attribute naming convention. The HTML structure and Tailwind classes look appropriate for this timestamp section.

package.json (1)

74-74: Document Storybook v8 migration steps

Upgrading from Storybook 7 to 8 is a major version change that includes breaking changes. Please:

  1. Document the migration steps in the PR description
  2. List any breaking changes that affect the NextUI project
  3. Provide guidance for NextUI users who need to upgrade

package.json Show resolved Hide resolved
@winchesHe winchesHe changed the title feat: upgrade storybook8 feat: upgrade storybook 8 Nov 20, 2024
@winchesHe winchesHe changed the title feat: upgrade storybook 8 chore: upgrade storybook 8 Nov 20, 2024
@winchesHe winchesHe changed the base branch from canary to beta/release-next November 20, 2024 14:31
@winchesHe winchesHe changed the base branch from beta/release-next to canary November 20, 2024 14:33
@wingkwong wingkwong added this to the v2.5.0 milestone Nov 20, 2024
@winchesHe winchesHe marked this pull request as draft November 21, 2024 02:24
@winchesHe
Copy link
Member Author

Still have some hot reload issues

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