-
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
Add new wrapContents prop to PluginSidebar #64273
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +22 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
It seems this should likely be the default and the opposite case (I need no padding at all because I'll handle stuff) to be an opt-out prop. Handling this through props is also not ideal. If there's a semantic need to have PanelBody we should encourage that explicitly. And if there is not, we should just make PluginSidebar have padding by default. Maybe the prop is more around spacing — cc @WordPress/gutenberg-components |
I agree completely but the issue is that all of the current implementations will get their UI "double wrapped" if it's opt-out. |
There is no semantic need to use Also, the devex isn't going to be as simple as "the container padding is enabled by default so I can just place my controls in there". There is still the problem of achieving consistent spacings between the controls. That's what Sidenote: However, the controls layout situation in the sidebar is currently a mess. Some components have bottom margins built in, which we are on the way to deprecating (#39358). On top of that, WordPress automatically applies a bottom margin on certain components (those based on |
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.
My $0.02: here's another group of reasons to consider this wrapContents
prop unnecessary:
- The most basic
PluginSidebar
example already includesPanelBody
. If there are any examples that don't use it, we could update them. - Having the panel body wrapper is achieved with basic component composability. Having the flexibility to compose components provides a better developer experience and a more expressive API than an arbitrary prop.
- This adds an extra way to add a
PanelBody
wrapper, which is unnecessary ambiguity, and that would contradict the WordPress philosophy without a good reason.
Thanks for the feedback everyone! Based on them, I'll close this out in favor of ensuring we have better examples in the docs. |
What?
This PR is an attempt at the implement for the solution proposed in #64272 to allow developers to define a basic UI wrapper for the content of a PluginSidebar.
Why?
As mentioned in #64272 this is a much better developer experience.
How?
I have added a new
wrapContents
prop that if true, will wrap thechildren
of the<ComplementaryArea />
component in a<PanelBody>
component.wrapContents
is false by default for backwards compatibility with existing implementations.Testing Instructions
wrapContents
istrue
, the content are wrapped (see screenshot below)wrapContents
isfalse
, the content are NOT wrapped (see screenshot below)Code
wrapContents is true
wrapContents is false
st