Skip to content

fix: Add prop table for modal story#532

Merged
nats12 merged 2 commits intomainfrom
mdx_modal_prop_table
Aug 10, 2021
Merged

fix: Add prop table for modal story#532
nats12 merged 2 commits intomainfrom
mdx_modal_prop_table

Conversation

@nats12
Copy link
Copy Markdown
Contributor

@nats12 nats12 commented Aug 4, 2021

Short description

During the upgrade to Storybook 6 and the shift to MDX stories, we noticed that the prop types for the Modal story weren't inferred due to its structure (a component with subcomponents with their own props and types as its type).
After a lot of researching online and creating a discussion in Storybook's repo, we have yet to find a way to automatically infer prop types of this component. Two workarounds were: a) inferring prop types from one of the actual stories i.e. Playground and not the component or b) manually set these props and their descriptions (the former wouldn't handle this). In this PR, I've attempted option b.

Granted it may not be the best solution, as any changes made to the Modal component will mean inconsistent prop types between itself and the story. But I'm struggling to see how we can get these inferred without completely changing the structure of our Modal component so that it's no longer a component made up of types.

This PR can serve as a bit of an exploratory area if we're not happy with this approach. Feel free to suggest alternative ways to achieve this or even contribute to this branch.

PR Checklist

  • Run storybook
  • Visit the modal story and click on it's Docs tab
    • Make sure you see a prop table with all the same Modal props we see under the Control tab
    • Make sure all props under this table have descriptions
    • Make sure that changing the prop's controls changes the Playground story.

@nats12 nats12 requested a review from frankieyan August 4, 2021 16:33
Copy link
Copy Markdown
Member

@frankieyan frankieyan left a comment

Choose a reason for hiding this comment

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

Using the Canvas instead of Preview seems to allow the right source code to be displayed in each example as well. Awesome!

Comment thread stories/components/Modal.stories.mdx Outdated
@nats12 nats12 merged commit 45f03c8 into main Aug 10, 2021
@nats12 nats12 deleted the mdx_modal_prop_table branch August 10, 2021 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants