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

Make addon-options work with story parameters #3958

Merged
merged 2 commits into from
Aug 6, 2018
Merged

Make addon-options work with story parameters #3958

merged 2 commits into from
Aug 6, 2018

Conversation

nm123github
Copy link
Contributor

@nm123github nm123github commented Aug 4, 2018

What I did

  • use makeDectorator to upgrade withOptions
  • update documentation

How to test

I've added usage to some stories in the marko-cli

addon-options-eg

If your answer is yes to any of these, please make sure to include it in your PR.

For maintainers only: Please tag your pull request with at least one of the following:
["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@storybook-safe-bot
Copy link
Contributor

Fails
🚫

PR is not labeled with one of: ["cleanup","BREAKING CHANGE","feature request","bug","documentation","maintenance","dependencies:update","dependencies","other"]

Generated by 🚫 dangerJS

@nm123github
Copy link
Contributor Author

Attempting to make addon-options use parameters. Few things,

  • I have not deprecated the global setOptions. I think its probably a good idea to let it be there but would like to know what others think.
  • Right now when you set options (using params) for a story, they get set globally. Ideally i would probably like it to be reset or something (maybe to the options we set using setOptions?) if we switch to a story where we don't set options. Is it possible to setOptions specifically for a story?

Copy link
Member

@ndelangen ndelangen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPER AWESOME!

@ndelangen ndelangen merged commit b4df20c into storybookjs:master Aug 6, 2018
@ndelangen
Copy link
Member

setOptions being persistent is expected behavior I think?

I don't see this as a big problem.

name: 'withOptions',
parameterName: 'options',
skipIfNoParametersOrOptions: false,
allowDeprecatedUsage: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nm123github -- was there a particular reason why you decided to allow deprecated usage for this decorator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed bunch of other add-ons that had set it to true, so presumed this was the pattern to follow and maybe there was a plan to set them to false at a later date.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. That option is to allow add('story', withOptions(() => <Story />)) style usage (which is the old way addons did it pre-4.0). Given this API never existed for withOptions I don't think we need it.

@shilman shilman mentioned this pull request Sep 1, 2018
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants