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

Restore isolated @automattic/components Storybook #97988

Merged
merged 2 commits into from
Jan 7, 2025
Merged

Conversation

mirka
Copy link
Member

@mirka mirka commented Jan 6, 2025

Proposed Changes

Restores ability to launch the @automattic/components Storybook in isolation.

Why are these changes being made?

The documentation was outdated.

#76007 moved the component stories into the root Storybook, and soon after #76794 restored the ability to launch the component stories in isolation. However, the README instructions are now outdated, likely due to the Storybook 7 upgrade.

Testing Instructions

yarn workspace @automattic/components run storybook to launch the isolated Storybook.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@@ -87,7 +87,7 @@
"clean:packages": "yarn workspaces foreach --all --parallel --verbose --exclude 'wp-calypso' run clean",
"clean:public": "rm -rf public",
"clean:translations": "rm -rf build/strings calypso-strings.pot chunks-map.*.json || true",
"components:storybook:start": "echo 'Storybook in Calypso moved into the root directory. Run `yarn storybook:start` instead.'",
"components:storybook:start": "echo 'Deprecated, run `yarn workspace @automattic/components run storybook` instead'",
Copy link
Member Author

Choose a reason for hiding this comment

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

This is more consistent with the other *:storybook:start scripts, e.g. composite-checkout:storybook:start.

@@ -41,6 +41,4 @@ in the root of the repository to get the required `devDependencies`.

### Using [Storybook](https://storybook.js.org/)

To see stories within this package, run `yarn workspace @automattic/components run start-storybook`.
Copy link
Member Author

Choose a reason for hiding this comment

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

start-storybook no longer works in Storybook 7+.

@@ -41,6 +41,4 @@ in the root of the repository to get the required `devDependencies`.

### Using [Storybook](https://storybook.js.org/)

To see stories within this package, run `yarn workspace @automattic/components run start-storybook`.

To see all stories within this repository, run `yarn storybook:start` at the root of the repository.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is untrue, as the root Storybook only includes a subset:

stories: [
'../client/**/*.stories.{js,jsx,ts,tsx}',
'../packages/design-picker/src/**/*.stories.{ts,tsx}',
'../packages/components/src/**/*.stories.{js,jsx,ts,tsx}',
'../packages/domains-table/src/**/*.stories.{js,jsx,ts,tsx}',
],

@@ -84,6 +85,7 @@
"scripts": {
"clean": "tsc --build ./tsconfig.json ./tsconfig-cjs.json --clean && rm -rf dist",
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets",
"prepack": "yarn run clean && yarn run build"
"prepack": "yarn run clean && yarn run build",
"storybook": "sb dev"
Copy link
Member Author

Choose a reason for hiding this comment

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

This script structure is consistent with the other packages that offer an isolated Storybook, e.g. launchpad or composite-checkout.

@mirka mirka marked this pull request as ready for review January 6, 2025 13:37
@mirka mirka requested a review from a team January 6, 2025 13:41
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 6, 2025
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks 👍 🚀

I'd say ideally, there should be a central storybook instance as well, one where you can see all stories from the entire monorepo, but that can be done separately.

@tyxla
Copy link
Member

tyxla commented Jan 6, 2025

Also, something for subsequent PRs: it seems like the instance needs some love and updates:

Screenshot 2025-01-06 at 18 46 57

@mirka mirka merged commit 97ae87d into trunk Jan 7, 2025
14 of 15 checks passed
@mirka mirka deleted the components-storybook branch January 7, 2025 12:48
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants