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

Add ability to hide dev-only stories from the production storybook #12971

Closed
4 tasks
tay1orjones opened this issue Jan 12, 2023 · 3 comments
Closed
4 tasks

Add ability to hide dev-only stories from the production storybook #12971

tay1orjones opened this issue Jan 12, 2023 · 3 comments
Labels
proposal: accepted This request has gone through triaging and we are accepting PR's against it. role: dev 🤖 type: docs 📖 type: enhancement 💡

Comments

@tay1orjones
Copy link
Member

tay1orjones commented Jan 12, 2023

In some instances, it's helpful to add a story to the storybook for development and testing purposes. These stories are not helpful to the consumer though, and would promote confusion if included in the production site/build.

For these cases, it would be nice if there was a way to add these stories, but have them in a special section that is not included in the production build.

#12971 (comment)

A few potential approaches

Use a environment flag to turn on/off dev mode

  • This dev mode would need to be applied in the netlify deploy preview environment. It is currently considered a 'production' environment, but we would want to show the dev stories for testing.
  • Ideally our CI and e2e tests would run against all these stories as well. This could be a good way to increase our visual snapshot coverage without introducing a bunch of stories that are only there for snapshotting purposes (e.g. input variants - readonly, disabled, etc.)

Option A:

Author stories in *.dev.stories.js files, and exclude these from the build in .storybook/main.js

  • Benefits: clear separation from production stories
  • Cons: does not live alongside other stories, more difficult to copy paste and maintain as component APIs change

Option B:

Author stories in the same file as production stories, but add a flag/prefix to their names, e.g. DEV_ReadOnlyInputExamples

I think ultimately the best approach right now could be to add the environment flag, and use option B

Concerns

  • This could become a wasteland dumping ground of unhelpful stories that are only used once for bug-repo/resovle.
    • To address, could we define some parameters around why/when we add a dev-only story vs not?
  • Visually snapshotting production and dev-only stories could quickly run up our snapshot count, exceeding the quota.
    • To address, could we provide a way for stories to be exempt from snapshotting to avoid running up our snapshot count?

Examples of stories that would be nice to have in a dev-only mode

@tw15egan
Copy link
Member

Adding to this, it would be nice to have dev-only stories that showcase the component in various states that could be run against Percy instead of running multiple snapshots against one component. For example,

Dropdown has a story for default, inline, inline with layer, and skeleton. It would be nice to dump all of these into one story and expand upon this by having variants in invalid and warning states, one that is opened, hovered, focused, etc., and only snapshot this file. That way, we can capture more style bugs before they happen.

I noticed this when making changes to the status-success token and anticipated Percy catching it. However, we only showcase the error notification, so Percy did not catch anything. It would be helpful to showcase each Notification variant in a story only seen in dev / Percy.

@sstrubberg
Copy link
Member

Due to some recent work @francinelucca had done to our Storybook the need for dev-only stories has diminished. Will revisit in the future if needed.

@sstrubberg sstrubberg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2023
@tay1orjones
Copy link
Member Author

Since this was opened, a separate idea was delivered that meets a lot of the use cases outlined here. We can now pass control/args configuration parameters on playground stories to the visitStory() function in e2e tests. It takes some of the wind out of the sails of this idea, and may outright eliminate it.

Are there other use cases where having dev-only stories would be helpful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal: accepted This request has gone through triaging and we are accepting PR's against it. role: dev 🤖 type: docs 📖 type: enhancement 💡
Projects
Archived in project
Development

No branches or pull requests

3 participants