Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for story parameters #71

Open
FrozenKiwi opened this issue Aug 31, 2023 · 1 comment
Open

Support for story parameters #71

FrozenKiwi opened this issue Aug 31, 2023 · 1 comment
Labels
status: help wanted Good idea, but the core developers will not work on it at the moment type: enhancement Improving upon an existing feature

Comments

@FrozenKiwi
Copy link

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
Copy link
Owner

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

const root = roots[0]
if (root.type !== 1 || root.tag !== 'Stories')
throw new Error('Expected root to be a <Stories> element.')
const meta = {
title: extractTitle(root),
component: extractComponent(root),
tags: [],
}

by adding the parsing of the parameters prop and then write it back at
return `export default {
${title ? `title: '${title}',` : ''}
${component ? `component: ${component},` : ''}
//decorators: [ ... ],
parameters: {
${docs ? `docs: { page: MDXContent },` : ''}
}
}

Let me know if you encounter any issues and I'm happy to help.

@tobiasdiez tobiasdiez added type: enhancement Improving upon an existing feature status: help wanted Good idea, but the core developers will not work on it at the moment labels Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted Good idea, but the core developers will not work on it at the moment type: enhancement Improving upon an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants