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-actions: Add Storybook Args support #10029

Merged
merged 18 commits into from Mar 13, 2020
Merged

Addon-actions: Add Storybook Args support #10029

merged 18 commits into from Mar 13, 2020

Conversation

shilman
Copy link
Member

@shilman shilman commented Mar 3, 2020

Issue: N/A

What I did

Storybook Args is a new format for stories that passes a dynamic data object "Args" into story functions. This can be used to automatically provide actions event callbacks into stories and components.

This PR adds two forms of Args compatibility using story parameters.

  1. argTypes.action that adds an action for each matching argType
  2. actions.argTypesRegex that adds an action for each arg type name that matches the given regex.

See the updated stories for examples.

How to test

See attached tests and official-storybook stories

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Looks good, couple of little things

```

Alternatively, suppose you have a naming convention, like `onX` for event handlers. The following configuration automatically creates actions for each `onX` argType (which you can either specify manually or generate automatically using [Storybook Docs](https://www.npmjs.com/package/@storybook/addon-docs).
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add an example of how you'd provide an argType to the story? Or is that sort of pointless?

Copy link
Member Author

Choose a reason for hiding this comment

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

Waiting on this until the argTypes design is finalized

addons/actions/src/preset/addArgs.ts Show resolved Hide resolved
addons/actions/src/preset/addArgs.ts Show resolved Hide resolved
@shilman shilman changed the base branch from feature/global-args to next March 11, 2020 07:07
@shilman shilman requested a review from jonspalmer March 11, 2020 07:17
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Lgtm

@shilman shilman merged commit fca0da0 into next Mar 13, 2020
@shilman shilman deleted the feature/action-args branch March 13, 2020 10:07
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.

None yet

3 participants