question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export stories as components

See original GitHub issue

This 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:22 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
tay1orjonescommented, Sep 16, 2019

5.2 is out! 🎉

3reactions
tay1orjonescommented, Jun 27, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found