vue-enterprise-boilerplate icon indicating copy to clipboard operation
vue-enterprise-boilerplate copied to clipboard

Integrate storybook for components

Open chrisvfritz opened this issue 7 years ago ā€¢ 22 comments

I'd like it to be pretty seamless and built into the main development workflow, so possibly as a <story> custom block inside .vue files.

chrisvfritz avatar Feb 20 '18 23:02 chrisvfritz

It also came to my mind, though Iā€™m worried the SFC file might get a bit crowded. But I guess this can be easily solved with an opt-in/opt-out prompt when using the component generator.

shentao avatar Feb 20 '18 23:02 shentao

Btw. it might be quite nice to include a Loki setup on top of Storybook.

shentao avatar Feb 21 '18 17:02 shentao

I would love to tackle this. Any ideas around what content you envision putting into that <story></story> block? For example ā€“

// PrimaryButton.vue
<template>
  <button :disabled="disabled">
    <slot></slot>
  </button>
</template>

<script>
export default {
  name: 'primary-button',
  props: ['disabled']
}
</script>

<story>
  <primary-button :disabled="true">Hello!</primary-button>
</story>

mattrothenberg avatar Mar 02 '18 15:03 mattrothenberg

What about something like

<story case="button is disabled">
  <primary-button :disabled="true">Hello!</primary-button>
</story>

<story case="button is enabled">
  <primary-button :disabled="false">Hello!</primary-button>
</story>

Not sure how to handle actions and variables though.

shentao avatar Mar 02 '18 15:03 shentao

@shentao Excellent, I like that API. I'll put together a proof-of-concept here shortly

mattrothenberg avatar Mar 02 '18 15:03 mattrothenberg

Repo: https://github.com/mattrothenberg/vue-storybook/ I wrote a custom Webpack loader that parses the <story> block and pulls out the requisite information.

mattrothenberg avatar Mar 02 '18 16:03 mattrothenberg

I like it! I'll be taking a closer look at this soon. šŸ˜»

chrisvfritz avatar Mar 08 '18 18:03 chrisvfritz

Hooray! I welcome any/all feedback, given I'm more of a designer than a dev šŸ˜ˆ

mattrothenberg avatar Mar 08 '18 18:03 mattrothenberg

@mattrothenberg Evan used to say that too. šŸ˜‰

chrisvfritz avatar Mar 08 '18 18:03 chrisvfritz

Just an update here: I'll finally be able to look into this a little more after VueConf next week, but am also a little bit torn. I'm playing with the possibility of using Cypress for component unit tests, instead of Jest, which would also provide a lot of the same benefits of Storybook. That would mean fewer tools for developers to learn, so if I can get it to work the way I want, I might be leaning in that direction.

chrisvfritz avatar Mar 23 '18 13:03 chrisvfritz

Sounds good @chrisvfritz. In either event, it was fun (and a great learning exercise) to get that vue-storybook idea out of my head and into code. Keep me posted!

mattrothenberg avatar Mar 23 '18 13:03 mattrothenberg

I'm playing with the possibility of using Cypress for component unit tests, instead of Jest

This is an interesting concept, any progress update?

patrickcate avatar Aug 01 '18 01:08 patrickcate

Hi all,

have some any news?

etroynov avatar Aug 19 '18 20:08 etroynov

Still experimenting - nothing I've tried so far has been ideal, but I'm not out of ideas yet. šŸ™‚

chrisvfritz avatar Aug 26 '18 16:08 chrisvfritz

Storybook has just released an alpha version with babel 7 support, and they have an officially plugin for storybook now. I guess we have to wait a bit longer, because the plugin is still not stable.

saintplay avatar Aug 26 '18 17:08 saintplay

@chrisvfritz: Could you elaborate on this topic? I see Storybook more as a living component documentation and development tool. As it mainly focuses on presenting components in different states. On the other hand Cypress can do unit testing and "behave like a user" respectively do proper end-to-end-testing.

I am curious: why do you think that Cypress (unit tests) give the the same (or some) benefits of Storybook?

riddla avatar Dec 07 '18 07:12 riddla

@riddla I think the Cypress client could potentially offer a superset of what Storybook does. For example, custom blocks such as <docs> and <story> in .vue files could work in combination with a custom Cypress command to not only display documentation and component states, but also demonstrate specific workflows and at the same time, actually confirm that each component works the way it should.

Does that make sense?

chrisvfritz avatar Dec 07 '18 19:12 chrisvfritz

good ! So how is it progressed now

smile921 avatar Jan 10 '19 03:01 smile921

Hello All, have you had a look at vue-styleguidist. it uses Markdown instead of JavaScript to write the examples in. Apart from that it does the same job as storybook... in <docs> block.

elevatebart avatar Feb 21 '19 13:02 elevatebart

Hi, I am trying to add storybook testing to the vue-enterprise-boilerplate. I already went through the learnstorybook tutorial for vue and it went smoothly. When I completed the setup in the vue-enterprise-boilerplate application and completed the tutorial code within this project everything worked except it doesn't pick up the styles. I tried everything I could think of but it just doesn't seem to pick up the styling at all in the storybook served test. Any ideas on what I can try next?

freddiv avatar Jun 27 '19 10:06 freddiv

No news about this? :(

abreumatheus avatar May 16 '20 01:05 abreumatheus

I get it working @abreumatheus and I'll try to pull request it soon.

marceloavf avatar Jul 23 '20 17:07 marceloavf