Code Monkey home page Code Monkey logo

storybook-addon-vue-info's Introduction

Deprecated

This addon is deprecated due to the retirement of official addon-info.

Storybook now has an alternative addon, called Docs addon(addon-docs), which comes with native Vue.js support and automatically props/events/slots documentation powered by vue-docgen-api.

There will be no feature addition nor bug fixes to this repo. Please use Docs addon instead.

Migration to Docs

As described above, Docs addon uses vue-docgen-api via vue-docgen-loader. They are also the tools storybook-addon-vue-info uses internally. So the migration steps is quite simple.

docgen tools are no longer peerDependencies

Since the Docs addon specifies vue-docgen-api and vue-docgen-loader as direct dependency, you don't have to list them in your package.json.

 "dependencies": {
-  "vue-docgen-api": "x.x.x",
-  "vue-docgen-loader": "x.x.x"
 }

Of course, you can keep them to controll which exact versions to use.

Explicitly specify which component to documentate

You need to set component field in your story metadata.

// foo.stories.js
import MyComponent from './my-component.vue'

export default {
  title: 'Components/MyComponent',
  component: MyComponent
}

export const story = () => ({
  components: { MyComponent },
  template: '<my-component/>'
})

Move summary inside a JSDoc comment or MDX

summary option equivalent in Docs addon is component comments or MDX. Docs addon reads a component comment and displays it as a description for the component.

// legacy.stories.js
export const myStory = () => ({
  /* ... */
})

myStory.story = {
  info: {
    summary: 'foo bar'
  }
}
<!-- component -->
<script>
  /**
   * foo bar
   */
  export default {
    /* ... */
  }
</script>

Or you can use MDX for more complicated usage.


logo

Build Status npm version Monthly download GitHub license code style: prettier


storybook-addon-vue-info

A Storybook addon that shows Vue component's information.

Requirements

  • @storybook/vue>=4.0.0

Getting started

First, install the addon.

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

# yarn add -D storybook-addon-vue-info

Then register in addons.js.

// .storybook/addons.js

// Don't forget "/lib/" !!
import 'storybook-addon-vue-info/lib/register'

And setup a webpack loader in order to extract component information with vue-docgen-api.

npm install --save-dev vue-docgen-loader vue-docgen-api

# yarn add -D vue-docgen-loader vue-docgen-api
// .storybook/webpack.config.js

// This example uses "Full control mode + default".
// If you are using other mode, add payload of `config.module.rules.push` to rules list.
module.exports = ({ config }) => {
  config.module.rules.push({
    test: /\.vue$/,
    loader: 'vue-docgen-loader',
    enforce: 'post'
  })

  return config
}

Usage

Add withInfo decorator then set info options to the story.

NOTE: info option is required for the addon. If you omit it, the addon does nothing.

import { storiesOf } from '@storybook/vue'

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

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

You can set the addon as global decorator.

// config.js
import { addDecorator } from '@storybook/vue'

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

addDecorator(withInfo)

To set default options, use setDefaults.

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

setDefaults({
  header: false
})

For more details, see live examples.

Options

Name Data type Default value Description
header boolean true Whether to show header or not.
source boolean true Whether to show source(usage) or not.
wrapperComponent Component default wrapper Override inline docs component.
previewClassName string undefined Class name passed down to preview container.
previewStyle Style object undefined Style passed down to preview container.
summary string '' Summary for the story. Accepts Markdown.
components { [name: string]: Component }|null null Display info for these components. Same type as component's components property.
docsInPanel boolean true Whether to show docs in addon panel.
useDocgen boolean true Whether to use result of vue-docgen-api.
casing "kebab" | "camel" | "pascal" | undefined undefined Which case to use. For detailed usage, see below.

Valid casing options

{
  // Don't convert names
  casing: undefined
}

{
  // Show names in kebab-case
  casing 'kebab'
}

{
  // Show prop names in camelCase and
  // Show component names in PascalCase
  casing: 'camel' // or 'pascal'
}

{
  // Show prop names in camelCase and
  // Show component names in kebab-case
  casing: {
    props: 'camel',
    component: 'kebab'
  }
}

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

Set descriptions manually

With vue-docgen-api, the addon automatically shows descriptions and types extracted by docgen (see example in vue-docgen-api README). However, if you want to explicitly specify desciprion for component props, events or slots, add description option for your story component.

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

storiesOf('MyComponent', module)
  .addDecorator(withInfo)
  .add(
    'foo',
    () => ({
      components: { MyAwesomeComponent },
      template: '<my-awesome-component/>',
      description: {
        MyAwesomeComponent: {
          props: {
            // These description will appear in `description` column in props table
            label: 'A label for my awesome component',
            visible: 'Whether component is visible or not'
          },
          events: {
            click: 'Event for user clicking the component'
          },
          slots: {
            default: 'Place text or icon here'
          }
        }
      }
    }),
    {
      info: true
    }
  )

For more detail, please take a look at live example.

Example

For real example, see example directory.

storybook-addon-vue-info's People

Contributors

adrianjost avatar aokiken avatar dartist21 avatar dependabot[bot] avatar devcrossnet avatar femioladeji avatar lambdalisue avatar pocka avatar the1975 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

storybook-addon-vue-info's Issues

Mixin props are not imported

Describe the bug
When using a mixin that declares props, storybook-addon-vue-info ignores them.

To Reproduce
mixin:

export default {
  props: {
   test: { type: String, required: true }
  }
};

component:

import mixin;
export default {
  mixins: [mixin]
};

Run storybook and observe the missing props in the prop table

Expected behavior
To see the props from the mixin merged appropriately

Desktop (please complete the following information):

  • OS: All
  • Browser: All
  • Version: NA

ENOENT: no such file or directory node_modules/highlight.js/tools/build.js

Describe the bug
Impossible to install the package actually

To Reproduce
Steps to reproduce the behavior:

  1. npm i storybook-addon-vue-info
  2. See the error about highlight.js

Expected behavior
Your dependency highlight.js has an error which break the install

Screenshots

40151 verbose stack Error: ENOENT: no such file or directory, chmod '/projectFolder/node_modules/highlight.js/tools/build.js'
40152 verbose cwd /projectFolder
40153 verbose Darwin 18.2.0
40154 verbose argv "/Users/user/.nvm/versions/node/v8.12.0/bin/node" "/Users/user/.nvm/versions/node/v8.12.0/bin/npm" "i"
40155 verbose node v8.12.0
40156 verbose npm  v6.5.0
40157 error path /projectFolder/node_modules/highlight.js/tools/build.js
40158 error code ENOENT
40159 error errno -2
40160 error syscall chmod
40161 error enoent ENOENT: no such file or directory, chmod '/projectFolder/node_modules/highlight.js/tools/build.js'
40162 error enoent This is related to npm not being able to find a file.
40163 verbose exit [ -2, true ]

Desktop (please complete the following information):

  • Version 0.7.1

Additional context

NPM install works fine without your package

JS not being transpiled on stories with the addon, including the example application

Describe the bug

JS in component <script> tags that are used by stories with this addon is not being transpiled by babel. The JS is being output straight to the browser, breaking storybook on IE11 or on any browser which does not support the JS written in the component.

This is true in the example application once babel-preset-env is enabled. If I have enabled it in a way that was not intended, I'd be happy to correct.

To Reproduce

Steps to reproduce the behavior:

Note yarn is used, the results are the same with npm.

  1. Clone this repository
  2. Install the example app. Note I had to change package.json to link to the app itself, I was unable to install with yarn due to the dependency being a file link.
  3. Add IE11 support - yarn add babel-preset-env
  4. Enable IE11 support - modify .babelrc to:
{
    "plugins": [
      "transform-vue-jsx"
    ],
    "presets": [
      "env"
    ]
}
  1. Start storybook with yarn storybook
  2. Open http://localhost:8080 in chrome and IE11
  3. Observe that chrome runs fine while IE11 is tripped up by the fat arrow functions in the example stories
  4. Edit stories/index.js to remove all references to storybook-addon-vue-info. Remove the plugin from .storybook/config.js. I've included my modified versions in the additional context section below to help with this, it's a bit of a hunt.
  5. Repeat 5 and 6 above to start the example app
  6. Observe that both Chrome and IE11 run the app fine. The fat arrow functions are properly transpiled.

Expected behavior

JS within the components are transpiled with babel like other JS

Desktop

Mac chrome (works) - whatsmybrowser.org/b/LPSGV93
Windows 10 chrome (works) - https://www.whatsmybrowser.org/37WYQNM
Windows 10 IE11 (does not work) - https://www.whatsmybrowser.org/97DBL37

Additional content

Modified files to remove storybook-addon-vue-info for testing purposes:

stories/index.js

import { storiesOf } from '@storybook/vue'

import BaseBlank from '../src/components/BaseBlank.vue'
import BaseButton from '../src/components/BaseButton.vue'

import NumberList from '../src/components/NumberList.vue'
import RenderFnComponent from '../src/components/RenderFnComponent'

storiesOf('BaseButton', module)
  .add('global component', () => ({
    template: '<base-button type="primary" label="global"/>'
  }))
  .add('local component', () => ({
    components: {
      LocalButton: BaseButton
    },
    template: '<local-button :disabled="true" label="local"/>'
  }))
  .add('long long template', () => ({
    template:
      '<base-button type="primary" disabled label="Storybook is a development environment for UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components."/>'
  }))
  .add('multiline template', () => ({
    template: `
      <base-button label="You can also use multiline template!">
      </base-button>
    `
  }))

storiesOf('Multiple components props', module)
  .add(
    'Shows multiple components props',
    () => ({
      components: { LocalButton: BaseButton, BaseBlank },
      template: `
    <div>
      <base-button label="I'm <base-button>"/>
      <base-blank/>
      <local-button label="I'm <local-button>"/>
    </div>
    `
    })
  )
  .add(
    'Specify which components will be shown',
    () => ({
      components: { LocalButton: BaseButton, BaseBlank },
      template: `
    <div>
      <base-button label="I'm <base-button>"/>
      <base-blank/>
      <local-button label="I'm <local-button>"/>
    </div>
    `
    })
  )

storiesOf('withInfo API', module)
  .add(
    'withInfo/1',
    () => ({
      template: '<base-button label="You can use withInfo API"/>'
  }))
    
  .add(
    'set .header=false',
    () => ({
      template: '<base-button label="No header info!"/>'
    })
  )
  .add(
    'set .source=false',
    () => ({
      template: '<base-button label="Without source"/>'
    })
  )
  .add(
    'set .style',
    () => ({
      template: '<base-button label="funny styled info"/>'
    })
  )
  .add(
    'set .summary',
    () => ({
      template: '<base-button label="awesome button"/>'
    })
  )
  .add(
    'pass summary strings to options',
    () => ({
      template: '<base-button label="My Awesome Button!"/>'
    })
  )
  .add(
    'Markdown summary',
    () => ({
      template: '<base-button label="See description"/>'
    })
  )
  .add(
    'JSX story',
    () => ({
      render(h) {
        return <base-button label="written in JSX" />
      }
    })
  )
  .add(
    'JSX story(2)',
    () => ({
      render(h) {
        return <BaseButton style={{ fontSize: '2em' }} label="Okay." />
      }
    })
  )

storiesOf('BaseBlank', module)
  .add('blank', () => ({
    components: { BaseBlank },
    template: '<base-blank/>'
  }))

storiesOf('NumberList', module)
  .add('A prop with `type: Array`', () => ({
    components: { NumberList },
    template: '<number-list :numbers="[3, 4, 5]"/>'
  }))

storiesOf('RenderFnComponent', module).add(
  'Works with non-SFC',
  () => ({
    render(h) {
      return <RenderFnComponent name="Vue" />
    }
  })
)

.storybook/config.js

import { configure } from '@storybook/vue'

import Vue from 'vue'

import BaseButton from '../src/components/BaseButton.vue'

Vue.component('base-button', BaseButton)

function loadStories() {
  require('../stories')
}

configure(loadStories, module)

Add description tab on property table

It would be very beneficial to have the ability to add a "descrition" field on the Components tabs.

This could be achieved by allowing developers to define a JS Docs comments on each of the property.

The approach may be similar to the one taken by react-styleguidist.

I am happy to help developing it if it is part of your roadmap

Hide Props section if there is none in the component

Is your feature request related to a problem? Please describe.
I've tried to use propTablesExclude for this with vue, but it doesn't work

Describe the solution you'd like
Hide Props section if there is none in the component, so it doesnt show the props table header and no content

Describe alternatives you've considered
Pass a boolean to hide Pros in settings, or do it automatically

Props, Events and slots are not showed in info pannel

Describe the bug

The Info(Vue) tab in story book does not show the props part. The only information I have in that part is the source code of my story

To Reproduce
Steps to reproduce the behavior:

  1. Configure webpack.config.json like that :
    module.exports async ({ config }) => {
     config.module.rules.push({
         test: /\.vue$/,
         loader: 'storybook-addon-vue-info/loader',
         enforce: 'post'
     });
    
     config.module.rules.push({
         test: /\.stories\.js$/,
         loaders: [require.resolve('@storybook/addon-storysource/loader')],
         enforce: 'pre'
     });
    
     return config;
    }
  2. Add this line in addons.js :
    import 'storybook-addon-vue-info/lib/register';
  3. My Story :
    import { storiesOf } from '@storybook/vue';
    import { withInfo } from 'storybook-addon-vue-info';
    import { withKnobs, text, object } from '@storybook/addon-knobs';
    
    import langManager from 'libs/i18n';
    
    storiesOf('Components/Dialogs/AqListDialog', module)
        .addDecorator(withKnobs)
        .addDecorator(withInfo)
        .add('Example', () => ({
            i18n        : langManager.getI18n(),
            data() {
                return {
                    showDialog : false,
                };
            },
            props : {
                title     : {
                    default : text('title', 'List Dialog'),
                },
                emptyIcon : {
                    default : text('Empty icon', 'people'),
                },
                items : {
                    default : object('Items', [
                        {
                            name        : 'Jean Claude',
                            subTitle    : '[email protected]',
                        },
                    ]),
                },
                itemName : {
                    default : text('Item Name', 'name'),
                },
                itemSubTitle : {
                    default : text('Item Sub Title', 'subTitle'),
                },
            },
            template : `
                <v-app>
                    <v-container grid-list-md>
                        <v-btn @click="showDialog = true">Show Modal</v-btn>
                        <aq-list-dialog
                            v-model="showDialog"
                            :items="items"
                            :item-name="itemName"
                            :item-sub-title="itemSubTitle"
                            :empty-icon="emptyIcon"
                            :title="title" />
                    </v-container>
                </v-app>
                `,
            propsDescription : {
                AqListDialog : {
                    items           : 'Items to show in the dialog',
                    itemName        : 'Attribute used to show the element name.',
                    itemSubTitle    : 'Attribute used to show the element subTitle.',
                    emptyIcon       : 'Icon showed if list is empty',
                    title           : 'Modal title',
                },
            },
        }), {
            info : true,
        });
  4. No props are showed in the info panel

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Versions

  • storybook-addon-vue-info: 1.0.1
  • @storybook/vue: 5.0.5

Unkown props type

Hi,

i got 'Unkown' props type

i defined props like this:

props: {
  disabled: Boolean
}

i guess modify src/getPropsInfoList.ts#L22 like below:

- type: constructorToString(prop.type),
+ type: constructorToString(prop.type || prop)

Crush when there are events with no payload

Describe the bug
An error is thrown when components have events that are emitted with no payload.

To Reproduce
Steps to reproduce the behavior:

  1. Set up docgen integration
  2. Create component
  3. Add method and write this.$emit('foo') into it
  4. Register component to a story
  5. See error

Expected behavior
No errors

Screenshots

screenshot 2019-02-02 at 02 40 21

Desktop (please complete the following information):

  • OS: ChromiumOS
  • Browser Chrome(Chromium)
  • Version 72

Warning: Each child in a list should have a unique "key" prop.

Hi, i'm working on a Vue Storybook project, i was working into Storybbok V4.1.3 and after upgrading it to the V5.0.2, i got

Warning: Each child in a list should have a unique "key" prop..

Previously i had no errors or warnings.
package.json:

"@storybook/addon-centered": "^5.0.2",
    "@storybook/theming": "^5.0.2",
    "@babel/core": "^7.1.6",
    "@storybook/addon-knobs": "^5.0.2",
    "@storybook/addon-links": "^5.0.2",
    "@storybook/addon-viewport": "^5.0.2",
    "@storybook/addons": "^5.0.2",
    "@storybook/vue": "^5.0.2",
    "@vue/cli-plugin-babel": "^3.5.1",
    "@vue/cli-plugin-eslint": "^3.5.1",
    "@vue/cli-plugin-unit-mocha": "^3.5.1",
    "@vue/cli-service": "^3.5.1",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/test-utils": "^1.0.0-beta.26",
    "autoprefixer": "^9.5.0",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.4",
    "babel-polyfill": "^6.26.0",
    "babel-preset-vue": "^2.0.2",
    "css-loader": "^1.0.1",
    "eslint": "^5.15.2",
    "eslint-plugin-vue": "^5.0.0",
    "file-loader": "^2.0.0",
    "node-sass": "^4.11.0",
    "postcss-loader": "^3.0.0",
    "sass-loader": "^7.0.1",
    "storybook-addon-vue-info": "^1.0.0",
    "storybook-readme": "^5.0.0",
    "storybook-vue-router": "^1.0.2",
    "vue-loader": "^15.7.0",
    "vue-style-loader": "^4.1.2",
    "vue-template-compiler": "^2.6.9"

button.stories.js

import { storiesOf } from '@storybook/vue'
import { withInfo } from 'storybook-addon-vue-info'

import AButton from './Button'

storiesOf('Atoms|Button', module)

  .addDecorator(withInfo)

  .add('Primary', () => ({
    components: { AButton },
    template: `
    <div class="row cell-3">
        <AButton 
            primary 
            content="Primary" 
        />
    </div>
  `,
    propsDescription: {
      AButton: {
        primary: 'Some prop description'
      }
    }
  }),
  {
    info: true
  })

addons.js

import 'storybook-addon-vue-info/lib/register'

I was wondering if there is something i'm missing with the new update, since everything was working just fine

Thanks for the help

Anonymous top level element breaks page

Describe the bug
Addon throws an error when top level component doesn't have name on runtime.

storiesOf('foo', module)
  .addDecorator(withInfo)
  .add('bar', () => ({ render: h => h(MyComponent) }))

To Reproduce
Steps to reproduce the behavior:

  1. Create component which is no name property
  2. Add story with render function
  3. Specify created component as first argument of h (or createElement)
  4. Error shown in preview

Expected behavior
No errors.

Screenshots
https://storybooks.slack.com/files/UAV0X1A5D/FAW6GSRU6/kapture_2018-05-24_at_12.35.12.mp4

Additional context
Reported by @zhaozhe0831 , Thanks!

Use library to cleanup story-source indentation

Is your feature request related to a problem? Please describe.
When I create a bigger story with a template that is more than one line long, the "story-source" output is usually much too indented (the way it is defined in the template).

Example:

	.add("test", () => ({
		template: `
			<div>
				div is starting 3 tabs indented
			</div>`,

Output: (way to much indented)

// Source:
			<div>
				div is starting 3 tabs indented
			</div>`,

Describe the solution you'd like
I found the library outdent which remove the leading indentation to start without indentation. This makes the output way cleaner. But using this for all templates seems a bit messy so I thought, why not implementing such a generic problem directly inside the source-rendering function of this plugin.

As far as I understand, you just need to add outdent to this line of code: StorySource/index.vue#L20

import outdent from 'outdent';
// ...
computed: {
  sourceCode() {
    return this.lang === 'jsx' ? outdent`;${this.source}` : outdent`${this.source}`
  }
},

Template starts with LF throws an error

Story that have template like below throws No registrated components found...

storiesOf('foo', module)
  .addDecorator(VueInfoAddon)
  .add('bar', () => ({
    template: `
  <my-component>
    <p>foo</p>
  </my-component>
  `
  })

Use JSX instead of Vue SFC

Using Vue SFC in library has many cons...

  • It requires additional compiler
    • and there are quite few to choose
    • Vueify (one of these) has changed it's peer dependencies and it breaks Netlify build (worse experience....)
    • It makes build process complecated and fragile
  • It has no type checking in template
  • Less IDE integration than JSX

Support a render function?

I know this is substantially more complicated to display "usage" for than a template string, but is there any chance we could get support for a render function, like the storybook official addon allows?

Add propTables options

  • propTables
  • propTablesExclude

  • If this options was empty, use outermost component without showing component title (backward compatibility).

support storybook 4 (5)

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

The current storybook version is 4. Also, the storybook team is planning to release version 5 (v5.0.0-alpha.1 is released already). Do you have a plan to support storybook v4 and v5?

Support for description

As in the info addon for react, it would be great to support for description as described in vue-styleguidist

A description column will be added to the table by a configuration.

Similar API to storybook/addons/info

This plugin currently supports only own addDecorator usage. It would be nicer if there are withInfo way.

Usage

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

storiesOf('my-component', module)
  .add('simple info', withInfo(`
    description or documentation about my component, supports markdown

    ~~~js
    <Button>Click Here</Button>
    ~~~
  `)(() => ({
    template: '<my-button>Click Me!</my-button>'
  }))
  .add('simple info with options',
    withInfo({
      styles: {
        header: {
          h1: {
            color: 'red'
          }
        }
      },
      summary: 'String or Vue Component with docs about my component'
    })(() => ({
      template: '<my-button>Click Me?</my-button>'
    }))
  )

Options

(Copied from storybook/addons/info)

{
  header: false, // Toggles display of header with component name and description
  inline: true, // Displays info inline vs click button to view
  source: true, // Displays the source of story Component
  propTables: [/* Components used in story */], // displays Prop Tables with this components
  propTablesExclude: [], // Exclude Components from being shown in Prop Tables section
  styles: {}, // Overrides styles of addon. The object should follow this shape: https://github.com/storybooks/storybook/blob/master/addons/info/src/components/Story.js#L19. This prop can also accept a function which has the default stylesheet passed as an argument.
  components: {}, // Overrides components used to display markdown
  maxPropsIntoLine: 1, // Max props to display per line in source code
  maxPropObjectKeys: 10, // Displays the first 10 characters of the prop name
  maxPropArrayLength: 10, // Displays the first 10 items in the default prop array
  maxPropStringLength: 100, // Displays the first 100 characters in the default prop string,
  TableComponent: props => {}, // Override the component used to render the props table
}

Support for vue-property-decorator

Is your feature request related to a problem? Please describe.
I use vue-property-decorator and Prop decorator, and addon don't generate any content :(

For example:

import { Prop, Component } from 'vue-property-decorator';
@Component
export default class PublicationListItem extends Vue {
  /**
   * First try
   */
  @Prop({ type: Number })
  /**
   * Oh my
   */
  public id!: number;

Is it vue-docgen-api issue?

overflowing usage text

i used a long text into template

and i got the horizontal scroll of InfoView.

i think the text should be in the box of the usage.

i guess modify InfoView.vue#L65 like this:

.code {
  overflow: auto;
}

Camel case components name doesn't load the props

Whenever I name my components as camel case the Props section in the info doesn't load.

For example:
I have a component called PlaceholderBox.vue. The code below doesn't load the "props"

import PlaceholderBox from '../components/PlaceholderBox'
import VueInfoAddon from 'storybook-addon-vue-info'

storiesOf('PromoList', module)
  .addDecorator(VueInfoAddon)
  .add('default', () => ({
    component: { PlaceholderBox }
    template: `<PlaceholderBox />`
  }))

screen shot 2018-08-17 at 15 52 11

However if I change the template to <placeholder-box /> then it loads the props

import PlaceholderBox from '../components/PlaceholderBox'
import VueInfoAddon from 'storybook-addon-vue-info'

storiesOf('PromoList', module)
  .addDecorator(VueInfoAddon)
  .add('default', () => ({
    component: { PlaceholderBox }
    template: `<placeholder-box />`
  }))

screen shot 2018-08-17 at 15 53 57

Is this an expected behaviour? If so can we have support for camel case components names?

Props are not inherited when extending a component

Describe the bug
When you extend a vue component, the parent's props are not displayed in the propstable.

parent-component

export default {
    props: {
        foo: String
    }
}

child-component

import parentComponent from './parent-component'

export default {
   extends: parentComponent
}

When I write a story for child-component I expect the property foo of the parent-component to be visible in the info props table - which it is not.

Allow to wrap several components in a div

sometime I want my example to be a bit ore complex than just adding my custom components, for instance: presenting several of my components wrapped by a template. today when you do that you get an error.

An example for such template:
image

The result error:
image

I guess that this is because the addon tries to fetch the info from the root component, and as this is not a custom component it fails to do so.

My suggested solution is to allow wrapping the template with a div tag, and the addon will ignore it and will consider the first child element as the custom component in that case

Thanks!

Let's collaberate!

Hey @pocka !

This is a great addon, thank you so much for creating this!

Would you care working together on a docs-view mode in the code of storybook?

Essentially the react-info and this addon will render docs about a component as a wrapper inside the iframe.
This is problematic long term for tools that integrate with storybook. So taking this documentation into the manager frame instead is something I'm currently working on.

Highly value your ideas and input, want to work together and chat on our discord? https://discord.gg/sMFvFsG

Planned deprecation

Current status (Update: Nov 14)

Docs-Mode is now available in Storybook v5.2.0!
If you want well-integrated, SB native looks, and easy to use documentation, please try it!
(documentation for events and slots are available from v5.3.0)


This is a remind issue.

It seems that Storybook team plans to add docs-view mode, which has almost the same features to info addon.
I think when it comes this addon is no longer necessary. It should go to maintenance mode then.

Source exposes decorators

Describe the bug
I've got a Card component that expands to fill its parent but doesn't make sense to present without a grid Container decorator. However I probably don't want to expose this grid Container decorator as the source, which seems to be how this is working.

Is there a way around this currently? unsure if this is a bug or expected behaviour (in which case a feature request!)

To Reproduce

import { storiesOf } from '@storybook/vue'
import VueInfoAddon from 'storybook-addon-vue-info'

// the component we wish to showcase
import Card from './index.vue'

// import our wrapper component to be used in the decorator, which we want to hide
import Container from '../Container/index.vue'

storiesOf('Card', module)
  .addDecorator(() => ({
    // Decorated with Container component
    components: {
      Container
    },
    template: '<container><story/></container>'
  }))
  .addDecorator(VueInfoAddon)
  .add('Card', () => ({
    components: { Card },
    template: '<card uri="/" text="Card title"></card>'
  }))

Expected behavior
I had hoped the source would show:
<card uri="/" text="Card title text"></card>

Instead this is currently showing:
<container><story/></container>

Obviously we'd ideally like this to automagically get the expected source, but I am not really across how decorators work in storybook and am unsure if it's possible?

Alternative Proposal
As a fallback second-best idea: One way I can imagine this working is to change the above example to use withInfo, in which case, could the source option also accept a string?
eg:

storiesOf('Card', module)
  .addDecorator(() => ({
    // Decorated with Container component
    components: {
      Container
    },
    template: '<container><story/></container>'
  }))
  .add('Card', withInfo({
    source: '<card uri="/" text="Card title text"></card>'
  })(() => ({
    components: { Card },
    template: '<card uri="/" text="Card title text"></card>'
  })))

A little clunky though (not DRY). Keen to hear thoughts on this issue.

Issue when using template literals

This throws an error No match components registered: utc-btn

storiesOf('UtcBtn', module)
  .addDecorator(VueInfoAddon)
  .add('Default', () => ({
    template: `
      <UtcBtn>
        Default
      </UtcBtn>
    `
  }))

However, when everything in the template literal is on the same line the issue goes away:

storiesOf('UtcBtn', module)
  .addDecorator(VueInfoAddon)
  .add('Default', () => ({
    template: `<UtcBtn>Default</UtcBtn>`
  }))

Any idea what's going on here?

Crush when components does not have any props

Describe the bug

An error is thrown when there are no props on the component.

To Reproduce
Steps to reproduce the behavior:

  1. Set up docgen integration.
  2. Create a component that does not have any props
  3. Add it to a story
  4. Wrap the story with withInfo
  5. See error

Expected behavior
No errors, no props table

Screenshots
screenshot 2019-02-02 at 02 36 16

Desktop (please complete the following information):

  • OS: ChromiumOS
  • Browser Chrome (Chromium)
  • Version 72

css property 'color' should not be defined in .vue-info

hello sir
may I ask you to slove below probrem?

Describe the bug

The `color` you define in `.vue-info` will override my storybook's style. I think it is better to remove.
(all color of original components become `#333`,,,)
https://github.com/pocka/storybook-addon-vue-info/blob/master/src/components/InfoView.vue#L103

I'm waiting for your good answer.
thank you

Missing slots, props, description for splitted components

Hi,

I have one question. My vue component is splitted to multiple files, in this case there are missing events/slots and description generated from comments. Below simple example.

<template src="./Label.html" />

<script>
  import instance from "./Label.js"

  export default {
    ...instance
  }
</script>

<style lang="scss" src="./Label.scss"/>

image

Is there any option adjust it in my storybook's webpack config or other way to make it working.

BTW. I like this addon so much.

Thanks in advance!

Bug with Vue-i18n

Describe the bug
When I try to use your addon in a component with a default value setted by Vue-i18n, I have this basic error :

TypeError: this.$t is not a function

To Reproduce
Steps to reproduce the behavior:

  1. Create a component with a default property setted with VueI18n :
    {
        textAdd : {
            type : String,
            default() {
                return this.$t('globalAddItem');
            },
        },
    }
  2. Set StoryBook as decorator in your stories (I have this error with withInfo and the decorator)
  3. Launch storybook
  4. Go to your component page

Expected behavior
Use correctly the Vue-i18n extension and know/translate the vue-i18n string

Desktop (please complete the following information):

  • OS: macOS mojaves
  • Browser : Chrome
  • Version : 0.7.0

Show error message if vue-docgen-api fails to parse component

Is your feature request related to a problem? Please describe.
It's hard to debug when vue-docgen-api fails to parse components(#82, #83 ). There's no error/warning message about it and the addon just shows only props table. Too bad UX!

Describe the solution you'd like
Emit an error or warning if vue-docgen-api threw an error.

Describe alternatives you've considered
hmm... add the note to README?

Array type props displayed as unknown

Props with type: Array are displayed as Type=unknown in the props table.
Additionally, when it has default which is factory function that returns default value, there are function's source code in the props table...

screenshot-2018-1-31 storybook

Allow to disable props table

Is your feature request related to a problem? Please describe.
I try to display a story for a feature, not a single component. Hence source and props are useless in my case. I can hide the source by setting the source: false option. It would be great to have the same option for props table

Describe the solution you'd like
propsTable: false will allow hiding props table

Add option to add info in a panel instead of in the iframe

Having all extra info in the iframe isn't that good, because your styling/scripts of the actual component and the info around it can interfere with each other. This is something to be avoided. I have been creating toolkit for a long time now, and you really don't want to have this. Therefore two things can be done:

  • Make it possible to show the info in a panel instead of the preview area
  • Make it so that the info is put around the iframe (which I don't know is possible with Storybook)

I didn't look at the code, but I assume it isn't that much work to add the option to render the info in a side panel?

Use decorator interface

Is your feature request related to a problem? Please describe.
It seems that storybook recommend using .addDecorator API. We should use it!

Describe the solution you'd like
Implement that feature.

Describe alternatives you've considered
Describe reason to README

Vue-info breaks knob addon

Describe the bug
@pocka I really like your addon, however there seems to be a problem.

The storybook knobs addon seems not to work with the vue-info addon. When changing a prop by using a knob it has no effect on the rendered component's prop.

Currently I'm using vue-info version 1.0.0-beta.0, knobs 4.1.11 together with storybook version 4.1.11.

To Reproduce
.storybook/addons.js
import 'storybook-addon-vue-info/lib/register'
import '@storybook/addon-knobs/register';

.storybook/config.js
import { configure, addDecorator } from "@storybook/vue";
import { withKnobs } from '@storybook/addon-knobs';
import { withInfo } from 'storybook-addon-vue-info'
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const req = require.context('../src/components', true, /\.story\.js$/)
function loadStories() {
req.keys().forEach((filename) => req(filename))
}
addDecorator(withInfo);
addDecorator(withKnobs);
configure(loadStories, module);

/src/components/Label.vue

<template>
<p>Hello{{ description }}</p>
</template>
<script>
import Vue from 'vue'
export default Vue.extend({
props: {
description: {
type: Text,
default: 'Hello'
}
}
})
</script>

/src/components/Label.story.vue

import { storiesOf } from '@storybook/vue'
import { text } from '@storybook/addon-knobs'
import Label from './Label.vue'
storiesOf('Wizard', module).add(
'with info and knobs',
() => ({
components: { Label },
props: {
description: {
type: String,
default: text('Description', 'This should work.')
}
},
template: '<Label :description="description"/>'
}),
{
info: {}
}
)

Expected behavior
When changing a prop via knob the related prop should be changed and rerendered.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.