-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Panel: Remove knobs from stories #46958
Conversation
@@ -8,13 +8,13 @@ import classnames from 'classnames'; | |||
*/ | |||
import { forwardRef } from '@wordpress/element'; | |||
|
|||
const PanelRow = forwardRef( ( { className, children }, ref ) => ( | |||
const PanelRow = ( { className, children }, ref ) => ( |
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.
Tweaked the export so the displayName isn't borked.
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.
Interesting that this is enough! I though we had to name-export PanelRow
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.
This was super weird, because the original code would show the display name as [object Object]
😕 I don't think I've ever seen that before.
Aside from that, I'm still unclear on why behavior seems inconsistent between "named but unexported" and "named and exported". Sometimes it works without an export, sometimes it doesn't 🤷
header: 'My panel', | ||
children: ( | ||
<> | ||
<PanelBody title="First section"> |
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.
Changed the default story to have multiple bodies so it looks more like a Panel.
function ScrollableContainer( { children } ) { | ||
return ( | ||
<div | ||
style={ { | ||
width: 300, | ||
height: '100vh', | ||
overflowY: 'auto', | ||
margin: 'auto', | ||
boxShadow: '0 0 0 1px #ddd inset', | ||
} } | ||
> | ||
{ children } | ||
</div> | ||
); | ||
} | ||
|
||
function Placeholder( { height = 200 } ) { | ||
return <div style={ { background: '#ddd', height, width: '100%' } } />; | ||
} |
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.
Removed these for simplicity. Placeholder
can be particularly confusing because we have an actual wp-component called Placeholder
.
Size Change: -7 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Flaky tests detected in 0c4c8e8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3860042814
|
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.
Great work! LGTM 🚀
One thought — previously, the knobs also exposed the opened
prop for the PanelBody
component. I assume it's not available in the list of controls because we can't display a control for a subcomponent ?
Out of curiosity — if it was possible to display it, I imagine our approach would be to leave it undefined
by default ("uncontrolled" mode), and let the user edit the controls (making it a "controlled" component) ? Just wondering :)
@@ -8,13 +8,13 @@ import classnames from 'classnames'; | |||
*/ | |||
import { forwardRef } from '@wordpress/element'; | |||
|
|||
const PanelRow = forwardRef( ( { className, children }, ref ) => ( | |||
const PanelRow = ( { className, children }, ref ) => ( |
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.
Interesting that this is enough! I though we had to name-export PanelRow
It is technically possible, just it would be confusing as documentation since we're sticking to a strict 1:1 relationship between "control" and "component prop". (Or maybe that's what you meant 😄)
Yeah I'd have to think about it, but this might be one of the cases where it's worth adding a story specifically to highlight Controlled mode. Because I feel like most people would want to use it uncontrolled. (Unlike form components, where most people use them controlled.) |
Part of #35665
What?
Remove the Knobs add-on from
Panel
stories.Why?
This is now a blocker for supporting npm 8 (#46443).
How?
Just a quick, minimal refactor.
Testing Instructions
npm run storybook:dev
Panel
component.