Addon-docs: Support non-story exports in module story format
See original GitHub issueStorybook docs is shipping with a new story format for ES6 modules based on this gist that treats all named exports as stories.
Opening this issue as a place to discuss how we might also support non-story exports. This came up in https://github.com/storybookjs/storybook/issues/6995 but it is a generally useful feature for exporting reusable story data.
Here’s a simple example for the discussion:
export default {
title: 'components/Button'
}; // stories metadata
export normal = () => <Button>Hello button</Button> // a story
export someData = { foo: 1, bar: 2 } //????
Three proposals so far from @tmeasday / @ndelangen / @shilman include marking individual stories, specifying story exports, and filtering non-story exports.
Marking stories
export normal = () => <Button>Hello button</Button>;
normal.isStory = true;
Which could be stylized as:
import { story } from '@storybook/story';
export normal = story(() => <Button>Hello button</Button>);
Specifying story exports
export default {
title: 'components/Button'
storyExports: ['normal'] // defaults to all exports as stories
};
...
Filtering non-story exports
export default {
title: 'components/Button'
ignoreExports: ['someData'] // defaults to all exports as stories
};
...
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
storybook/addon-docs
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into clean, ...
Read more >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 >storybook/core-server: Versions
Vite: Export storybook utilities from frameworks for better pnpm support #19216 ... Addon-docs: Fix canvas support expand code for non-story #18808 ...
Read more >@storybook/addon-docs | Yarn - Package Manager
how to introduce significant new features (e.g. vue support, story hierarchy)?; how to converge on key design decisions (e.g. new addons API)?; how...
Read more >storybookjs/storybook (Raised $170.00)
[Bug]: non-story content not working with angular components. Unfunded#19696created byadmir86 ... Module '"@storybook/vue3"' has no exported member 'app'.
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
I think if we can make the black/whitelist easily configurable via params, then we shouldn’t have a default – to me that falls under the purview of magic that the user might not know about and find hard to debug (why is my story
_iLoveUnderscores
not showing up?)Hint: To use the new feature you can now allowList using
includeStories: ['myStory1', ...]
or blockList usingexcludeStores: ['myNonStoryExport', ...]
inexport default