-
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
Dimension Tools and Controls #28356
Comments
Started working on some of these. First thing is adding padding block support to dynamic blocks. |
Started working on the margin block support in #30371 |
Padding server-side support flag is now merged. |
I ran into needing a margin today. This will be such an important tool to build great patterns. |
As @jasmussen says, margin support seems to be one recurring tool required by many theme blocks to build rich patterns. |
I saw that a PR for adding support for margins to the site title block was merged. |
I'm conflicted here. On the one hand, I deeply want this feature for better patterns. On the other hand, the current margin controls are very clunky, and there isn't a #27331 inspired design for how we surface margin/spacing in a user-friendly way yet. For example while we might know by heart the difference between margin and padding, this is not necessarily obvious for the average user — so do we put margin and padding behind a segmented control? Do we take up space and have controls for both visible at the same time? Is there an alternative that better abstracts the controls? It's a difficult design, and every feature we surface adds weight, even if it's a collapsed-by-default panel. Question: can we enable margin support for all blocks through theme.json and markup, without surfacing the UI for it yet? While not the most obvious interface for building patterns, at least it would be technically unblocked as we refine the UI for it. |
Margin block support was added in #30608. I'm also starting to work on updating the spacing support panel into the proposed "Dimensions" panel. Once I have that in place, the plan is I'll add height and width support to that. |
There is a proof of concept up for the Dimensions panel in #32392. It focuses on adding a new component that can easily be reused across multiple block supports. The individual block support controls for margin and padding can be updated as the G2 component matching the design gets imported in the near future. The linked PR uses the new component to convert the current Spacing support panel into the basis for the new Dimensions panel. I'll be adding height and width support to it soon. |
Added this to the design tools project overview, apologies for all the assignments above. https://github.com/orgs/WordPress/projects/10/views/1 |
Hi all, looking to continue this discussion. Now that things are much more solidified as we get closer to 5.9, I believe it makes sense to explore adding additional dimension controls (the editor UI) to more block types for post-5.9 releases. I have begun by creating a PR for paragraph blocks #37300 and here is the related issue #37299. I will also be working on PR for the Group block to include both margin and blockGap later this week. Given that theme developers can easily opt-in/out of this functionality in theme.json, I believe this is only enhances the capabilities of the block Editor with very little, if any, downside. It also greatly reduces the need for custom CSS and/or "magic classes" to attain certain theme designs. |
Thanks for looking into this followup @ndiego. Out of all the dimension tools, margin is the trickiest to expand, particularly to non-layout blocks, because it's not easy to grasp how it works or how it interacts with adjacent margins. It also makes it difficult to reason about when it comes to boundaries — like deciding where to add a margin within or outside template parts. Towards 6.0 I'd like us to explore using the Spacer block as a replacement for most margin needs. I know this sounds backwards, but the spacer block is a lot more intuitive for end users to reason about, they can move it separate from the rest of the blocks, they can manipulate it directly, etc. On flex layouts, the spacer can better reflect organization and adapts to vertical or horizontal displays. There's also nothing preventing us from transforming a spacer block into adjacent margins server-side if we want to avoid rendering an empty element in the DOM. If we do this correctly, I can see a world where margin is left as an advanced tool for creators, more hidden by default. |
Thanks for the thoughtful response @mtias! I completely agree that the spacer block is much more intuitive and is great when users need to add spacing between blocks. The use-case that the spacer block does not solve is removing margin, particularly in Note that I am operating from the standpoint of wanting to be able to design entirely in the Editor. If a theme's style.css file could be completely empty of custom CSS, that would be my dream state. Regardless of the correct solution to this dimensions issue, and I know that |
I created #38068 which contains mockups for improving the Image block inspector, notably adopting the general Dimensions panel. |
This is a sub part of #27331
The tools to configure the spacing of a block are among some of the most incoherent tools we offer, with controls usually scattered across different panels and standalone tools. (See #23770, #24874, #26368, #22956, #14747.)
The proposed dimensions panel emerges as the consolidation of controls relating to the space a block occupies on the page. This includes but is not exhausted by height, padding, width, possibly alignment, and so on. Much like the typography panel, these controls are not always going to be present for every block, so it’s important individual controls can be toggled on and off as required, and that blocks can expose those that are considered default options based on configuration. The focus in this exercise is to test how the different controls ought to be laid out.
Let's try to split the work needed to achieve the proposed output in these mockups:
Height Control
Question Should the height attribute be its own block attribute or should it be part of the "style" attribute.
Width Control
I'm not talking here about the "full width"/"wide width" UI here but more about the "width" control we have right now in some blocks like "column" or "button". Basically the equivalent of the height control shown as an input.
Question Should the attribute be its own block attribute or should it be part of the "style" attribute.
Padding
We do have an existing support flag for padding, so we need to adapt it to work consistently to the other controls.
Margin
The primary focus for this is to provide a spacing option between the blocks that can work globally.
Block Alignments
What we call block alignments is the "full width"/"wide width" UI shown in the mockups and sometimes it can include "left/right"... We do have a support flag for these called "align" but it has a few issues: It's not used consistently in blocks, some blocks have their own custom "align" support. Another problem is that it uses the "align" attribute which might have a different meaning in some other blocks.
The other issue here is that this control only make sense in the "default" layout (Meaning if the container is just a normal vertical list of blocks). In different layouts like the "flex" layout (which already exists in the code base but in an implicit way using the "orientation" prop), these alignments don't make any sense.
I think here we need to be more generic and instead of talking about "block alignments" we should just talk about "position". So inside a "default" layout container, the values can be "wide"/"full"/"left"/"right"/"center"/"none" but inside a "flex horizontal" container, these values don't apply and inside an "absolute container", we might have "x and y", inside a "grid" container we might have something else (rows, columns)
So I think what's important here at the moment is to scale down the scope to the "default" layout but we keep in mind how this attribute should or shouldn't translate to other future layouts.
Based on this, here's what I think should be the plan here:
The text was updated successfully, but these errors were encountered: