-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Bug] Story name can conflict with imports #10
Comments
You can add an 'id' attribute to a Story component to override the generated story id. Id are used in MDX docs and in the URL. I'm not sure if it's a good idea to add a magic prefix here.. |
Agreed that the magic prefix could be confusing for complex use cases where you want to use the resulting export. I think the current behaviour is also a bit unexpected as it does not match how other formats work, though I guess as long as the story id prop is documented on the final version it would be fine as a workaround. Thanks for the quick response on this |
This is indeed pretty unfortunate. It took me quite a while to figure out what's going on. It's pretty common to have components like PrimaryButton, SecondaryButton etc. I'd like to have a story with the same name for each one, and group them together as a "Button"/"Buttons" component. So basically, the following structure:
The walkaround seems to be to use the name of the component in the Meta title, and call the Story something arbitrary, like "Default". That works, but looks peculiar IMHO:
|
@jankalfus you just have to specify explicitly your story id
|
That doesn't seem to work, unfortunately. If I use the following code, the story doesn't appear:
On the other hand, this one:
|
In csf the stories are named exports. You can't export "default", it's already used. You have to choose another id |
You can set the display name to default in CSF using the storyName annotation. Also to achieve the nav you want, check out single-story hoisting https://storybook.js.org/docs/react/writing-stories/naming-components-and-hierarchy/ |
In the loader at:
addon-svelte-csf/src/parser/svelte-stories-loader.ts
Line 51 in b0010e5
There's some generated code that exports each story by their name. This conflicts with imports so for example you can't have something like this (modified from the example code):
Since it will try to declare Button again.
I believe this could be as simple as adding a prefix to the generated export name, such as "Story" and that seems to work locally but I am not familiar enough with the code and whether this would break something else to send a pull request for it.
The text was updated successfully, but these errors were encountered: