storybook-eol / addon-smart-knobs

🧠 This Storybook plugin uses @storybook/addon-knobs but creates the knobs automatically based on PropTypes.
https://storybooks.js.org
217 stars 36 forks source link

Groups of knobs to organize multiple components on the same page #75

Closed bastienrobert closed 3 years ago

bastienrobert commented 4 years ago

If the same component is several times in the same story, groups are automatically generated based on the children's index in order to put them in tabs and prevent conflicts between props.

Also, it fix the documentation page issue in storybook/addon-knobs.

Maybe it would be possible to customize these names to make groups more verbose.

Fix. https://github.com/storybookjs/addon-smart-knobs/issues/71

bastienrobert commented 4 years ago

About this:

Maybe it would be possible to customize these names to make groups more verbose.

Maybe we could read a props on children components (like __groupId) in the stories to get more verbose names?

bastienrobert commented 4 years ago

Seems like I'm having another issue when using addon-docs. If component is not wrapped, it doesn't receive props properly in the doc page. I have to do something like:

const Wrapper = (props) => <MyComponent {...props} />

export const Story = () => <Wrapper foo="bar" />

I just don't understand why it does have this behavior.

ndelangen commented 4 years ago

Could you merge in the base branch please?

bastienrobert commented 4 years ago

I just did it @ndelangen but maybe it'll be necessary to check this : https://github.com/storybookjs/addon-smart-knobs/pull/75#issuecomment-602032718 and to fix this : https://github.com/storybookjs/addon-smart-knobs/pull/75#issuecomment-602291443 ?

ndelangen commented 4 years ago

That's strange, that behavior should just work, I think you're using CSF there?

bastienrobert commented 4 years ago

Yes I am. I just wanted to start with a basic setup before looking to make it works with MDX Syntax (because I'm using Typescript).

Maybe another PR to add more documentation on how to setup Storybook docs with Typescript and MDX here storybook docs could be cool ?

ndelangen commented 4 years ago

@shilman is working on a replacement for knobs that has this auto-feature built-in btw.

Any PR improving the docs would be welcome!

bastienrobert commented 4 years ago

Ok, that's cool! Maybe you have a date for a release? 🙃

ndelangen commented 4 years ago

6.0.0 is scheduled for release next month or so. It depends on how many bugs we find during prereleases.

nikshevchenko commented 4 years ago

Hi, folks! Can you talk about the status of this PR? I using 6.0.2 but I have the same problems with my multiple components.

chriszarate commented 4 years ago

Just a note that Storybook v6 and @storybook/addon-essentials have been released, including the "Controls" addon. You can think of Controls as smart knobs, with the added benefit that they can be embedded on Docs pages using ArgsTable.

I am not a maintainer, but I'd consider this addon effectively dead since Controls have resolved all open issues I had with Smart Knobs (including this one) and leapfrogged it in terms of functionality.

bastienrobert commented 4 years ago

I agree with @chriszarate, this PR is clearly useless for v6 because this addon is useless for v6.

@nikshevchenko I don't think having multiple components in the same story is a good practice. Is your code opensource or could you setup a bug repro? Can't help without more informations.

@ndelangen is this repo going to be archived or do you want to keep it active? Maybe this question should be in another issue?

ndelangen commented 3 years ago

@bastienrobert I think it's best archived, I'll ask @shilman