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

addon-controls - Better documentation for custom options controls #10947

Closed
SebDuf opened this issue May 27, 2020 · 8 comments
Closed

addon-controls - Better documentation for custom options controls #10947

SebDuf opened this issue May 27, 2020 · 8 comments

Comments

@SebDuf
Copy link

SebDuf commented May 27, 2020

Is your feature request related to a problem? Please describe.
I was playing around the new addon-controls, but I had trouble finding how to implement a custom radio control for a prop with limited options

Describe the solution you'd like
An example of how to use the options controls, I had to dig into the tests to find out how to use them properly (eg: a combination of controlType', type and options)

Describe alternatives you've considered
An example in the addon-controls doc that shows a custom option control scenario

Are you able to assist bring the feature to reality?
Not for a PR, but here's my working story for inspiration:

export const Primary = (args) =>{
  return <Button {...args} >Button</Button>;
};

Primary.argTypes = {
  variant: {
    control: {
      controlType: 'radio',
      options: [
        'primary',
        'secondary',
        'outlined',
        'text-only',
      ],
      type: 'options'
    },
    defaultValue: 'primary',
  }
};

Additional context

{
"name": "input",
"control": {
"type": "options",
"options": [
1,
2
],
"controlType": "radio"
}
}

@sami616
Copy link

sami616 commented May 28, 2020

Yes, this issue helped me figure out how to use this too. Is it documented anywhere on how to exclude props from the output too?

@shilman shilman added this to the 6.0 args milestone May 28, 2020
@shilman shilman self-assigned this May 28, 2020
@shilman
Copy link
Member

shilman commented Jun 1, 2020

Great Caesar's ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.20 containing PR #11003 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jun 1, 2020
@shilman
Copy link
Member

shilman commented Jun 1, 2020

@SebDuf i actually changed the API in #11003 ... there were unfinished changes and I finished those and added a bit of documentation

@shilman
Copy link
Member

shilman commented Jun 1, 2020

@sami616 There are include/exclude properties on the Props component if you're using MDX (list of fields or regex). If you're using typescript, you can actually configure this via propFilter on the loader, see: https://github.com/storybookjs/storybook/blob/next/docs/src/pages/configurations/typescript-config/index.md#L36

@sami616
Copy link

sami616 commented Jun 1, 2020

@shilman is there a way to exclude from the controls, but keep in the prop table?

@shilman
Copy link
Member

shilman commented Jun 1, 2020

@sami616 If your stories don't use args, the controls won't show up. There probably should be a prop for that as well.

@shilman
Copy link
Member

shilman commented Jul 2, 2020

@sami616 I added a way to selectively disable controls & rows #11388

@shilman
Copy link
Member

shilman commented Jul 2, 2020

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.39 containing PR #11388 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants