JoJk0 / storybook-addon-vue-slots

Vue slots support for Storybook.js
MIT License
17 stars 5 forks source link

Is this add-on still relevant with Storybook 7-and-up ? #18

Closed kalnode closed 5 months ago

kalnode commented 7 months ago

I'm using SB7 and am able to pass content into Vue slots... without this add-on:

MyComponent.vue

<template>
  <div>
    <slot></slot>
  </div>
</template>

MyComponent.stories.ts

export const MyStoryA: Story = {
  args: {
    default: 'This content appears in the default slot'
    // or even:
    // default: '<Button :primary='true'>Some kind of button</Button>'
  }
}

Granted, I haven't gone very deep with slot features, In any case...

Does this add-on still do something useful in relation to Storybook version 7-and-up ?

Consider SB7 is their biggest update ever with full support for Vite and lots of improvements for Vue. https://storybook.js.org/blog/storybook-7-0/ https://github.com/storybookjs/storybook/pull/20498?ref=storybookblog.ghost.io

jbogheand commented 7 months ago

When I try to pass it html code it escapes it/displays as a string This code

args: {
    default: `
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
      <div>5</div>
    `,
  }

Displays like this: image

JoJk0 commented 5 months ago

Yes, this addon is still relevant as of Storybook 7 / 8. It is meant to be for convenience purposes to simplify the writing of slots and reduce redundancy. You can also achieve the same without the addon and you can use render() function to change the way the component is shown in story. Inside of them, you can use Vue template and write slots as you normally would inside SFC's template section.