Revise "Playground" story approach in the @carbon/react
storybook
#16816
Labels
package: @carbon/react
@carbon/react
proposal: open
This request has gone through triaging. We're determining whether we take this on or not.
type: enhancement 💡
Milestone
Context
The
@carbon/react
storybook has supported this use case so far via the storysource plugin. It displays the code source of the current story being shown in the canvas. It meets this need fairly well if the story uses explicit values within the story.Click to expand example
Although when controls/args are used, the source code doesn't work well for copy/paste because it contains storybook-specific code (
...args
) that would cause an error in any environment outside of our storybook:Click to expand example
As-is experience
To combat this we have so far tried to follow a strategy where we only use controls/args on a single specific story named "Playground". Each component typically has one - controls are fully enabled, and other stories have explicit prop usage instead of controls. This way the story source is copy/paste-able for every story except the Playground story.
In some cases Playground stories can't be used because the component has variants that require different stories and aren't able to be contained in one Playground story. Button and StructuredList are an example of this currently. In these cases controls are enabled on every story and there is no Playground story.
This strategy and it's inconsistency is confusing for both maintainers and users of the storybook.
Proposal
Stories are intended to be authored using args. Every story should be updated to use args where possible. We could then delete the playground stories.
Another way to think about this is that we're renaming
Playground
stories to beDefault
. The goal isn't to encourage adding a new story for every variant of a component - instead this change encourages further reduction of stories towards greater reliance on args.There are a few ways we can continue supporting the copy/paste use case:
type
option:Additional benefits of this approach include:
The text was updated successfully, but these errors were encountered: