Skip to content
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

Storybook docs description for primary slot #9468

Closed
AlekseyPn opened this issue Jan 15, 2020 · 12 comments
Closed

Storybook docs description for primary slot #9468

AlekseyPn opened this issue Jan 15, 2020 · 12 comments

Comments

@AlekseyPn
Copy link

Hi, i need help.
How i can write description for primary slot with vue story, and how i can describe props or events, i have not found how i can do it.
And i have not found describes for parameters.docs api. I lost many hours in tried find describes((

@shilman
Copy link
Member

shilman commented Jan 15, 2020

@AlekseyPn
Copy link
Author

Screenshot_20200117_184644

@shilman Thanks for reply, I talk about that example, on the third line "description" rendered by JSDoc, from this example https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/docspage.md#description
But when i use it in my stories with vue, it doesn't applied

@shilman
Copy link
Member

shilman commented Jan 17, 2020

Does this help? 3bcaaeb

@HoraceKeung
Copy link

HoraceKeung commented Jan 20, 2020

It works and would like to share the following info from my experience in case of any misunderstanding:

  1. The comment for the description should be inside the Vue single file component, not in the story
  2. The comment must be right above this line of code: export default {
    i.e.
<script>
import Another from '~/components/Another'
/**
 * Component description
 */
export default {...}
</script>

The above will work and the below will not

<script>
/**
 * Component description
 */
import Another from '~/components/Another'
export default {...}
</script>
  1. It won't apply if the story is written with MDX (and it is expected I believe)

@shilman
Copy link
Member

shilman commented Jan 21, 2020

@HoraceKeung thanks! for MDX, you should be able to do:

import { Description } from '@storybook/addon-docs/blocks';
import { Component } from './component';

<Description of={Component} />

@AlekseyPn
Copy link
Author

@HoraceKeung Thanks!!!

@HoraceKeung
Copy link

HoraceKeung commented Jan 21, 2020

@shilman Thank you! Would like to mention that in Vue, it is import Component from './Component';, also I think it should be import { Description } from '@storybook/addon-docs/blocks'; Speaking of docs blocks, I couldn't find documentation regarding all the available docs blocks, but I guess it is coming soon on this page? https://storybook.js.org/docs/formats/mdx-syntax/

@shilman
Copy link
Member

shilman commented Jan 21, 2020

@HoraceKeung thanks, fixed. yes docs coming soon 🙈

@annacv
Copy link

annacv commented Jun 18, 2020

Use JSDoc, like this: https://github.com/storybookjs/storybook/blob/next/examples/vue-kitchen-sink/src/stories/components/InfoButton.vue

Hi @shilman it works properly :) But, what about slots, how can we add a slots' description? I've noticed it "catches" the slot when used as a tag (instead of using it as <div slot: 'bla'/>) but I'm not achieving how to customize the description. Any idea? Thks!

@ecarrera
Copy link

ecarrera commented Jul 22, 2020

@annacv you can describe slots with @slot tag.

<template>
  <div>
    <!-- @slot Use this slot header -->
    <slot name="header"></slot>

    <!--
      @slot Modal footer
      @binding item an item passed to the footer
		-->
    <slot name="footer" :item="item" />
  </div>
</template>

Here is the reference: https://github.com/vue-styleguidist/vue-styleguidist/tree/dev/packages/vue-docgen-api#slots

@MatthijsBe
Copy link

Is there any other way to do this, or exclude this on a production build?

My point is that when I inspect any component that uses @slot description it also shows in the dom.

image

@alexcroox
Copy link

Has anyone managed to define this subheader in their story? Looking at the storybook documentation for the docs page i just can't get it to work, I've tried:

export default {
  title: `Forms/Form Elements/${Component.name}`,
  component: Component,
  docs: {
    description: {
      story: 'A subheader of the docs page here'
    }
  }
}
export default {
  title: `Forms/Form Elements/${Component.name}`,
  component: Component,
  componentSubtitle:  'A subheader of the docs page here'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants