1.0.0-alpha.7 • Published 7 years ago

storybook-addon-vue-info v1.0.0-alpha.7

Weekly downloads
19,697
License
MIT
Repository
github
Last release
7 years ago

Build Status npm version Monthly download GitHub license Top Language GitHub last commit code style: prettier

A Storybook addon that shows component's information.

Screenshot

Install

npm install --save-dev storybook-addon-vue-info

Usage

Wrap story with withInfo function.

import { storiesOf } from '@storybook/vue'

import { withInfo } from 'storybook-addon-vue-info'

storiesOf('MyComponent', module).add(
  'foo',
  withInfo({
    summary: 'Summary for MyComponent'
  })(() => ({
    components: { MyAwesomeComponent },
    template: '<my-awesome-component/>'
  }))
)

You can specify default options with setDefaults.

// config.js
import { setDefaults } from 'storybook-addon-vue-info'

setDefaults({
  header: false
})

NOTE: Using this addon as decorator is deprecated (detail).

Setup docgen loader

// .storybook/webpack.config.js
module.exports = {
  // ...
  module: {
    // ...
    rules: [
      // ...
      {
        test: /\.vue$/,
        loader: 'storybook-addon-vue-info/loader',
        enforce: 'post'
      }
    ]
    // ...
  }
  // ...
}

NOTE: This loader tries to attach component's meta generated by vue-docgen-api, but sometimes Module not found error occures in dev mode then rebuilded immediately.

Options

This addon accepts @storybook/addon-info like options.

NameData typeDefault valueDescription
headerbooleantrueWhether to show header or not.
sourcebooleantrueWhether to show source(usage) or not.
wrapperComponentComponentdefault wrapperOverride docs component.
summarystring''Summary for the story. Accepts Markdown.
components{ [name: string]: Component }\|nullnullDisplay info for these components. Same type as component's components property. If null or false, this addon tries to use components property in story component then outermost tag in template.
docsInPanelbooleantrueWhether to show docs in addon panel.
useDocgenbooleantrueWhether to use result of vue-docgen-api.

In addition to addon options, we have a component option.

propsDescription

If you want to add desciprion for component props, you can add propsDescription option for your story component.

Assume <my-awesome-component> have props label and visible.

storiesOf('MyComponent', module).add(
  'foo',
  withInfo({})(() => ({
    components: { MyAwesomeComponent },
    template: '<my-awesome-component/>',
    propsDescription: {
      MyAwesomeComponent: {
        // These description will appear in `description` column in props table
        label: 'A label for my awesome component',
        visible: 'Whether component is visible or not'
      }
    }
  }))
)

Example

For real example, see example directory.

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-beta.1

7 years ago

1.0.0-beta.0

7 years ago

1.0.0-alpha.9

7 years ago

1.0.0-alpha.8

7 years ago

1.0.0-alpha.7

7 years ago

1.0.0-alpha.6

7 years ago

1.0.0-alpha.5

7 years ago

1.0.0-alpha.4

7 years ago

1.0.0-alpha.3

7 years ago

1.0.0-alpha.2

7 years ago

1.0.0-alpha.1

7 years ago

1.0.0-alpha.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago