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.

addon-docs: Descriptions per Story

See original GitHub issue

Issuehunt badges

Is your feature request related to a problem? Please describe.

According to the documentation there is currently one Description section on a DocsPage. This section is filled by the JSDoc comment /** */ used by my specified component. That’s awesome. I can place a general description here. (E.g. describe what my component <Button />.)

After that I have more specific stories showcasing different usages of a certain component. (E.g. showcasing <Button mode="primary" /> and <Button mode="secondary" />.)

It would be lovely if I could add a JSDoc comment to my stories so they show up on the DocsPage. E.g. something like that:

import React from 'react';
import { Button } from '../../src/components/button';

export default { title: 'Components|Button', component: Button };

export const All = () => (
  <>
    <Button mode="primary">Click me!</Button>
    {' '}
    <Button mode="secondary">Click me!</Button>
  </>
);

/**
 * Only use me once per page for the preferred user action.
 */
export const Primary = () => <Button mode="primary">Click me!</Button>;

/**
 * You can use me several times on a page for neutral actions.
 */
export const Secondary = () => <Button mode="secondary">Click me!</Button>;

Describe the solution you’d like

Everything could than be rendered like this:

image

Describe alternatives you’ve considered

I could use MDX files for this, but they currently lack any type checking which I’d like to keep (and I don’t really want to separate every example out of the MDX file into their own files, because I don’t know if this messes with things like the Source Loader for code examples 🤔). Also it’s a little bit easier to migrate to for existing Storybooks instead of rewriting everything to MDX.

Are you able to assist bring the feature to reality?

Probably, I can if I find a little bit of time.


IssueHunt Summary

shilman shilman has been rewarded.

Backers (Total: $100.00)

Submitted pull Requests


Tips

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:125
  • Comments:51 (27 by maintainers)

github_iconTop GitHub Comments

31reactions
izhancommented, Mar 3, 2020

Hey folks – long-time watcher of this thread here! I ended up creating a trivial Webpack loader a while back that got the job done. I only now had some extra time to put it on Github, which you can find here.

Code

// A `primary` button is used for emphasis.
export const Primary = () => <Button primary>Submit</Button>

/**
 * Use the `loading` prop to indicate progress. Typically use
 * this to provide feedback when triggering asynchronous actions.
 */
export const Loading = () => <Button loading>Loading</Button>

Output

Definitely not perfect and a bit specific to my codebase’s current setup, hence some quirks here and there. But figured I’d send it out in case anyone was looking for a starting point.

Also happy to improve on it more, but looks like there’s bigger, better plans brewing in this thread. Eager to help there too 😃

14reactions
issuehunt-app[bot]commented, Jan 15, 2021

@kylemh has funded $100.00 to this issue.


Read more comments on GitHub >

github_iconTop Results From Across the Web

Description - Storybook - JS.ORG
Storybook's Description Doc Block displays the component's description obtained from its source code or user-generated content. Docs blocks with description ...
Read more >
@storybook/addon-docs | Yarn - Package Manager
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into clean, readable pages ...
Read more >
Compare DocsPage and MDX syntax in Storybook with example
MDX gives you lot of freedom to create free-form pages for each component, ... card.stories.mdx --> import { Meta } from '@storybook/addon-docs/blocks'; ...
Read more >
@storybook/addon-docs - npm
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into ...
Read more >
In Storybook how can you display the full source of a ...
SomeComponent.stories.mdx import { Meta, Story, Preview, Props } from '@storybook/addon-docs'; import HugeComponentShowcase from ...
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