storybook: Addon-docs: StoryDescription is not shown for first story
Describe the bug
For the first story after storiesOf
, any storyDescription
is not shown.
To Reproduce Steps to reproduce the behavior:
- Add a new file
button.stories.js
- Add a storyDescription to the first story (see code snippets below for an example)
- Take a look at this in storybook in the “Docs” view
Expected behavior
The storyDescription
should show, just like it does for any other story.
Code snippets
storiesOf("Button", module)
.add("vanilla", () => (
<button>My vanilla button!</button>
), {
docs: {
storyDescription: `
My button description
`,
},
})
System:
Please paste the results of npx -p @storybook/cli@next sb info
here.
Environment Info:
System: OS: macOS 10.14.6 CPU: (4) x64 Intel® Core™ i7-7567U CPU @ 3.50GHz Binaries: Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm Browsers: Chrome: 76.0.3809.132 Safari: 12.1.2 npmPackages: @storybook/addon-a11y: ^5.2.0 => 5.2.0 @storybook/addon-docs: ^5.2.0 => 5.2.0 @storybook/addon-storysource: ^5.2.0 => 5.2.0 @storybook/addon-viewport: ^5.2.0 => 5.2.0 @storybook/react: ^5.2.0 => 5.2.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 23 (11 by maintainers)
@shilman @domyen - There are a couple of thoughts I had regarding this:
HeaderWithLink
andHeaderWithoutLink
, there isn’t really a primary story. Therefore, I’m not sure if this is the default pattern to follow.If the encouraged pattern is to have a
BaseButton
orBaseHeader
configurable story, I think the documentation should encourage that from the beginning. Having said that, my contention is that this should not be the default. I’ve found the same issues as @donaldpipowitch and it seems unintuitive for most cases.Thank you!
Apologies for the late reply everyone 🙏. There seem to be two issues here:
StoryDescription
is missing from the primary story (the one at the top) of the DocsPage. I agree that this is an oversight. My strawman is to put the description (only) here.The idea of “Primary” stories Docs was designed to feature one representative story for each component. This is common practice amongst the design systems we researched like Shopify Polaris, Workday Canvas, and Auth0 Cosmos. But I get that not everyone is going to have the same mental model – that’s why DocsPage is fully customizable.
There are a few things we can do here:
I don’t think it makes sense to eliminate the primary story concept because a use case we’d like to support in 6.0 is live adjusting that story via the ArgsTable. I think this behavior with make the primary distinction make a bit more sense.
I don’t know… every time I write stories I stumble over this issue. I think it would be nice if Storybook would not emphasize the first story by default. It should be treated like the other stories and there should be a way to write a more general introduction/description unrelated to a specific story, if needed. But just my opinion. It’s probably too late to get this into v6?
(Update: Workaround for v6-rc:
But I still think it is an UX gotcha. 🤔)
I too have been looking for hours for a way to ignore the “primary” story and show all the stories in the docs-page right below the (automatically generated) “Stories” title.
Almost none of my stories makes sense to have a “primary” story.
I want the docs-page to document all the stories, as equal, one after the other
Not sure why the
includePrimary
is not included in the normal configuration of ajsx
file for a story. It seems pretty weird for me to override the full page config to just adding a flag.Any update on this?
@domyen we can make it work. I’m going to add this to my todo list and i’ll circle back to it shortly.
Sounds good?
@shilman Can you take a look at the PR? Thanks
Was able to find the bug. In
DocsPage.tsx
The first story is printed by the
Primary
component and the rest of the stories are printed with theStories
component. In primary component DocStory is called as<DocsStory {...story} expanded={false} withToolbar />
Expanded is set asfalse
here hence it is not printing the title and description. What was the design decision here. A simple fix is passing expanded as true. @shilman What do you think about this fix? Hopefully it does not break anything else. Will run tests to check that. Opening a PR soon.