-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
storybook: create type table component #84282
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.
looks great on the video 👏
function groupByParent(props: PropItem[]) { | ||
return props.reduce( | ||
(acc, prop) => { | ||
acc[prop.parent?.fileName ?? ''] = (acc[prop.parent?.fileName ?? ''] ?? []).concat( | ||
prop | ||
); | ||
return acc; | ||
}, | ||
{} as Record<string, PropItem[]> | ||
); | ||
} |
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 think we could leverage the built-in Object.groupBy
method here:
Object.groupBy(props, prop => prop.parent?.fileName ?? '');
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.
Til about this method
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #84282 +/- ##
===========================================
+ Coverage 56.15% 87.64% +31.49%
===========================================
Files 9572 9564 -8
Lines 542163 540723 -1440
Branches 21264 21279 +15
===========================================
+ Hits 304434 473943 +169509
+ Misses 237377 66425 -170952
- Partials 352 355 +3 |
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.
LGTM overall, huge improvement! Few suggestions but will leave the final call up to you.
Co-authored-by: Nate Moore <[email protected]>
This PR exposes the type documentation generated in #84169 and #84166 to the user via a searchable table component and a story provided documentation helper. You can see an example of prop documentation added to the button.stories.tsx, which follows the current convention of storybook providing the helper that should be called by the user. ``` export default storyBook('Button', (story, APIReference) => { APIReference(types.Button); story('Default', () => ... ); ``` Note that the call order does not matter, the documentation (if provided) is being displayed under the components. In a perfect world, this should really work by passing the component itself to the API (the types can be stored directly on the function itself), however that is currently just not feasible as a broader loader implementation cripples the devserver to a point where it is not usable... The only notable design decision is that given how exhaustive our type generation is, I have decided to prioritize the props that are defined inside the component while other types which the component might extend from remain collapsed (users can expand them and they will show when searching), which https://github.com/user-attachments/assets/53fbea3c-7aea-4054-bfb9-1b4079b80f2d I do not consider this final and there are still aspects of this that I would like to improve, such as adding visual cues to indicate prop types, improving the type extraction and possibly breaking this down into smaller type definitions instead of files (sometimes the props are a merge of multiple different types defined in a single component) --------- Co-authored-by: Nate Moore <[email protected]>
This PR exposes the type documentation generated in #84169 and #84166 to the user via a searchable table component and a story provided documentation helper.
You can see an example of prop documentation added to the button.stories.tsx, which follows the current convention of storybook providing the helper that should be called by the user.
Note that the call order does not matter, the documentation (if provided) is being displayed under the components. In a perfect world, this should really work by passing the component itself to the API (the types can be stored directly on the function itself), however that is currently just not feasible as a broader loader implementation cripples the devserver to a point where it is not usable...
The only notable design decision is that given how exhaustive our type generation is, I have decided to prioritize the props that are defined inside the component while other types which the component might extend from remain collapsed (users can expand them and they will show when searching), which
CleanShot.2025-01-29.at.18.42.12.mp4
I do not consider this final and there are still aspects of this that I would like to improve, such as adding visual cues to indicate prop types, improving the type extraction and possibly breaking this down into smaller type definitions instead of files (sometimes the props are a merge of multiple different types defined in a single component)