Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Making work with react-native-storybook. Adding some features #8

Merged
merged 2 commits into from
Mar 29, 2017
Merged

Conversation

Gongreg
Copy link
Contributor

@Gongreg Gongreg commented Mar 28, 2017

Making this addon work with react-native-storybook.

Added dependency storybook-addon-actions, so this addon would also work with react-native-storybook. It replaces @kadira/storybook dependency (react-native-storybook doesn't have this dependency).

Adding some features

  • Added checking if props exist, because if they are undefined plugin crashes.

  • Returns clone of element instead of already wrapping element into withKnobs, since we still need to do withKnobs manualy and setting withKnobs before screws up usage with other addons (for instance storybook-addon-usage)

  • If there is no knob on prop, it will still use the passed prop, instead of returning undefined.

…rk with react-native-storybook.

Added checking if props exist, because if they are undefined plugin crashes.
Returns clone of element instead of already wrapping element into withKnobs, since we still need to do withKnobs manualy and setting withKnobs before screws up usage with other addons (for instance storybook-addon-usage)
If there is no knob on prop, it will still use the prop, instead of returning undefined.
@lucasconstantino
Copy link
Contributor

Thanks for your effort here! I think this pull-request closes both #5 and #7, am I right?

@Gongreg
Copy link
Contributor Author

Gongreg commented Mar 28, 2017

Give me few minutes to inspect.

@Gongreg
Copy link
Contributor Author

Gongreg commented Mar 28, 2017

Talking about #5, I think it solves that problem, but doesn't display any warning about it.
About #7, it allows to set your own knobs, but then knobs are duplicated (displays both your own set knob and smart knob). I will look into it whether we can check if user has already set his own knob.

@Gongreg
Copy link
Contributor Author

Gongreg commented Mar 28, 2017

Alright, I've added example of manual knob. This indeed allows to use them.
You just need stub addon as first decorator.

Simple explanation of why it works:

When adding a stub decorator first, it simply creates a component, that means it creates the stubs that you have written manually. Then, when smart-knobs go to create default knobs, they are not created, because knobs manager already sees the knobs named same way.

@lucasconstantino lucasconstantino merged commit 731b94b into storybook-eol:master Mar 29, 2017
@Gongreg
Copy link
Contributor Author

Gongreg commented Mar 29, 2017

Oh, I forgot to tell, that this should have been a breaking change..

Since smart knobs are not wrapping knobs anymore, you need to add both decorators in your storybook.

But I think it is a good thing since you can add decorators between them (and I already gave an example in main pr comment where it is necessary).

@lucasconstantino
Copy link
Contributor

No worries. I've publish a new version 0.3.0 (and unpublished 0.2.3) so people might continue using 0.2.x. Thanks for your efforts here, really. I don't use this package very often, so I don't dedicate much time to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants