Export stories as components
See original GitHub issueThis issue is for tracking the effort of exporting Storybook story code as React components.
CC @jendowns
Summary/Justification
Some business units have created a design system based on Carbon. For such Carbon-based design systems, they have their own storybook but want to use some stories from Carbon.
Detailed design and usage example
This effort introduces modules like:
export default ({ ...props }) => (
<div>
<Button {...props} className="some-class">
Button
</Button>
<Button {...props} href="#" className="some-class">
Link
</Button>
</div>
);
Using that, Carbon-based design system can create a story like:
import ButtonStory from '/path/to/button-story';
storiesOf('Buttons', module)
.add(
'Default',
() => (<ButtonStory data-foo="Foo" />));
Specific timeline issues / requests
N/A
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:22 (15 by maintainers)
Top Results From Across the Web
Component Story Format (CSF) - Storybook
Every component story file consists of a required default export and one or more named exports. CSF is supported in all frameworks except...
Read more >Component Story Format - WebComponents.dev
Every component story file consists of a required default export and one or more named exports.
Read more >eslint-plugin-storybook/story-exports.md at main - GitHub
In CSF, a story file should contain a default export that describes the component, and at named exports that describe the stories.
Read more >What makes up a Story?
Every component story file consists of a required default export and one or more named exports. Default export#. The default export is what...
Read more >Storybook for React — Naming and Hierarchy - Medium
In the stories file, we export an object as the default export with the title and component properties. The title is what we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
5.2 is out! 🎉
We’d also like to see this for use in our Watson IoT addons.
Instances where we are simply wanting to render the story as-is, I have found that we can import the story from
node_modules
and then re-export it from a story file in our project. There’s some oddities with story source rendering and prop tables, but gives us a starting point.Something we’d like to do in our storybook is divide “stock” carbon components (re-exported components without modifications) from “extended/custom” components via the
hierarchySeparator
. This currently isn’t possible as there isn’t a way to modify the story name.