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

FCT-1112 | display story only when running storybook locally #2902

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

ByronDWall
Copy link
Contributor

feat(local only storybook): add ability to only display a story in the sidebar when running storybook locally by adding a 'local-dev' tag to the story meta

this is a POC - feedback welcome

@ByronDWall ByronDWall added the 🚧 Status: WIP Work in progress label Sep 11, 2024
@ByronDWall ByronDWall self-assigned this Sep 11, 2024
Copy link

vercel bot commented Sep 11, 2024

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

Name Status Preview Comments Updated (UTC)
ui-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 5:43pm
ui-kit-storybook-v8 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 5:43pm

Copy link

changeset-bot bot commented Sep 11, 2024

⚠️ No Changeset found

Latest commit: 74c0430

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

@@ -34,6 +34,6 @@
"start": "storybook dev -p 6006",
"build-and-serve": "yarn build & yarn serve",
"build": "NODE_ENV=production storybook build",
"serve": "serve"
"serve": "serve ./storybook-static"
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there an issue with this command? The serve tool config is in the serve.json file and refers to this folder already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly, yarn serve would crash bc it wasn't finding an index.html unless I specified the filepath.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fwiw, here is the output I get
Screenshot 2024-09-12 at 8 59 42 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

The only way I can reproduce this is by running the build-and-serve command and I quickly noticed why it happened: I forgot the second & character and the tasks are started in parallel instead of consecutive order 🤦

Can you fix this command and run it again, or run the build + serve commands manually one after another.
I just ran both commands from the project-root and from within the storybook folder and had no issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another reason I could imagine is that your system is picking up a globally installed version of serve which does not support the serve.json file yet. Is serve -v showing the version specified in the package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@misama-ct I spent entirely too long trying to understand what was causing different behavior on my machine, and I've found that what's causing the issue is that serve has a dependency serve-handler, which has a dependency on minimatch:3.1.2.

In our root package.json, we have a resolution to set minimatch to always resolve to ^9.0.0.

The syntax used to call minimatch in serve-handler is valid in 3.1.2, but not in 9.x, thus the error I am seeing.

We resolve the minimatch version to greater than 9.x because older versions have security vulnerabilities, and from what I can tell there is no way to tell yarn v3 to resolve 3.1.2 only for serve-handler.

I verified that this issue also occurs for @tylermorrisford when he installs main and attempts to run yarn serve.

So out of curiosity, how are you building packages for the monorepo? because I cannot get this to work without modifying something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@misama-ct I'm going to revert the change for the purposes of this PR - it can be handled separately if necessary.

@misama-ct
Copy link
Contributor

I like the tag + filter option. This would allow us to have one story-file with multiple stories and the capability to hide only specific ones.

One feature I'd love to have as well are mdx-files that only show up in development and I think you could do that easily by adding a new (or adjusting the existing) glob-pattern in the main.ts file.

e.g. *.dev.mdx files are only showing up in the dev-storybook.

@ByronDWall
Copy link
Contributor Author

One feature I'd love to have as well are mdx-files that only show up in development and I think you could do that easily by adding a new (or adjusting the existing) glob-pattern in the main.ts file.

e.g. *.dev.mdx files are only showing up in the dev-storybook.

I agree - my first approach was actually an attempt to update the globs in the main.ts stories.config to conditionally build *.dev.stories.ts, and let's just say that part of it was probably my lack of familiarity with glob patterns because it turned out to be more frustrating then expected.

I'll take another go at it though, because I like the pattern, especially if we can use it for mdx files as well.

…e sidebar when running storybook locally by adding a 'local-dev' tag to the story meta
…d documentation for local-dev tag in storybook/README.md
@vercel vercel bot temporarily deployed to Preview – ui-kit-storybook-v8 September 12, 2024 17:37 Inactive
import { Meta, Markdown } from '@storybook/blocks';
import ReadMe from './../README.md?raw'

<Meta tags={['local-dev']} title="components/Filters/FilterMenu/Readme" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@misama-ct we can use tags in the functional-component flavor of Meta for *.mdx. I think I prefer this over a separate glob-based approach in main.ts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice. Perfect.

@ByronDWall ByronDWall marked this pull request as ready for review September 12, 2024 17:40
@ByronDWall ByronDWall merged commit f2a6ec8 into FCT-1111-filters-init Sep 13, 2024
6 checks passed
@ByronDWall ByronDWall deleted the FCT-1112-local-storybook branch September 13, 2024 16:18
ByronDWall added a commit that referenced this pull request Sep 16, 2024
* feat(local only storybook): add ability to only display a story in the sidebar when running storybook locally by adding a 'local-dev' tag to the story meta

* feat(local only storybook): use tag in mdx files as well

* feat(local only storybook): add local story stubs for FiltersList, add documentation for local-dev tag in storybook/README.md

* fix(tag): remove local-dev tag from dropdownmenu readme
ByronDWall added a commit that referenced this pull request Sep 17, 2024
* feat(local only storybook): add ability to only display a story in the sidebar when running storybook locally by adding a 'local-dev' tag to the story meta

* feat(local only storybook): use tag in mdx files as well

* feat(local only storybook): add local story stubs for FiltersList, add documentation for local-dev tag in storybook/README.md

* fix(tag): remove local-dev tag from dropdownmenu readme
ByronDWall added a commit that referenced this pull request Sep 17, 2024
…2912)

* chore(readmes): run yarn generate-readmes and commit results

* feat(filters): add placeholder test files for unit and vrt tests, add versioning

* FCT-1112 | display story only when running storybook locally (#2902)

* feat(local only storybook): add ability to only display a story in the sidebar when running storybook locally by adding a 'local-dev' tag to the story meta

* feat(local only storybook): use tag in mdx files as well

* feat(local only storybook): add local story stubs for FiltersList, add documentation for local-dev tag in storybook/README.md

* fix(tag): remove local-dev tag from dropdownmenu readme

* fix(serve cmd): revert change specifying ./storybook-static filepath in storybook/package.json in order to merge local dev tagging to filters files branch

* feat(filter menu file structure): add component file for trigger button

* chore(spacing): change spacing in filter-menu

* chore(ci): ! for running checks
ByronDWall added a commit that referenced this pull request Sep 17, 2024
* feat(local only storybook): add ability to only display a story in the sidebar when running storybook locally by adding a 'local-dev' tag to the story meta

* feat(local only storybook): use tag in mdx files as well

* feat(local only storybook): add local story stubs for FiltersList, add documentation for local-dev tag in storybook/README.md

* fix(tag): remove local-dev tag from dropdownmenu readme
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