tobiasdiez / storybook-vue-addon

Storybook stories in native Vue format
MIT License
46 stars 1 forks source link

Support for story parameters #71

Open FrozenKiwi opened 1 year ago

FrozenKiwi commented 1 year ago

Hey, first, thanks for this awesome plugin!

I'm trying to integrate the figma design plugin though, and it doesn't appear the parameters object is being picked up? For comparison

const meta: Meta<typeof Button> = {
  title: 'Example/Button',
  component: Button,
  parameters: {
    design: {
      type: 'figma',
      url: '<tofigma>',
    }
  }
};

Correctly loads our designs in the design tab

<script>
const parameters = {
  design: {
    type: 'figma',
    url: '<tofigma>',
  }
}
</script>
  <Stories
    title="Example/Button2"
    :component="Button"
    :parameters="parameters" // <-- Not here
  >
    <Story
      title="PrimarySS"
      :parameters="parameters" // <-- nor here
    >
      <Button
        label="Button"
        :parameters="parameters" // really speculative now
      >
        Primary
      </Button>
    </Story>

I haven't dug much into the compilation process, but I was hoping/assuming that anything passed to Story would be passed through to the output.

Any thoughts on this? With a few pointers I wouldn't mind taking a crack at this if it's unsupported ATM

tobiasdiez commented 1 year ago

Yes, this is not yet supported.

Thanks for your offer to help. This should actually be pretty straightforward to implement. The starting point would be to extend https://github.com/tobiasdiez/storybook-vue-addon/blob/2d25010df85003aae69878b4883876817215b703/src/core/parser.ts#L63-L70 by adding the parsing of the parameters prop and then write it back at https://github.com/tobiasdiez/storybook-vue-addon/blob/2d25010df85003aae69878b4883876817215b703/src/core/transform.ts#L105-L112 Let me know if you encounter any issues and I'm happy to help.