-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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-docs: Refactor Props to use ArgsTable #10341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of smaller comments. Looks good.
Haven't tested it yet; I'll play with it as part of the controls PR
const { parameters } = context; | ||
const { component, subcomponents, args = {}, argTypes = {}, docs = {} } = parameters; | ||
const { extractArgTypes } = docs; | ||
// if (context.storyFn.length === 0 || !component || !extractArgTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should decide if we do this.
|
||
extractedArgTypes = Object.entries(componentArgTypes).reduce((acc, [label, compTypes]) => { | ||
Object.entries(compTypes).forEach(([key, argType]) => { | ||
const subLabel = label === 'Primary' ? key : camelCase(`${label} ${key}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary component doesn't get its arg names mangled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this needs to be thought of in combination with the story/primary component arg combination idea.
export const inferArgTypes = (args: Args) => { | ||
if (!args) return {}; | ||
return Object.entries(args).reduce((acc, [name, arg]) => { | ||
if (arg != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (arg != null) { | |
if (arg !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!= null
handles both null
and undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ughh, me no likey
// import camelCase from 'lodash/camelCase'; | ||
// Object.entries(subTypes).forEach(([key, val]) => { | ||
// const subLabel = camelCase(`${label} ${key}`); | ||
// acc[subLabel] = { ...val, table: { ...val.table, tab: label } }; | ||
// }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Co-Authored-By: Tom Coleman <[email protected]>
…to 6639-args-table
Issue: #6639
What I did
This is the first of a series of PRs to add controls (formerly known as "knobs") to the Props block:
This is the largest PR. It contains:
<Props story="story name" />
APIArgsTable
, a refactor ofPropsTable
that's based on ArgTypesIt is demonstrated in the
props.stories.mdx
demo, which will subsequently be enhanced with Controls in the follow-on PRHow to test
run
official-storybook
and navigate toAddons/Docs/props