Skip to content

Optimise and condense unlinked padding / margin controls #49264

Closed

Description

@jameskoster

What problem does this address?

When padding / margin controls are unlinked (for per-side settings) they occupy an enormous amount of real estate. It's particularly bad when you unlink both. On my 16" MacBook they fill the entire Inspector 🙈 :

Screenshot 2023-03-22 at 11 26 20

This feels especially bad when you only want to apply padding / margin to a single side which is not uncommon.

What is your proposed solution?

Use dynamic two-tone icons to let you select sides:

  1. All sides (split into separate axial controls) by default
  2. Individual sides
  3. Entirely custom per-side borders

Screenshot 2023-04-13 at 11 40 40


Issue updated Apr 13.

See initial proposal

I think we can optimise for single-side value application by allowing folks to choose where the padding / margin is applied in a popover menu containing the following options:

  • All sides (default)
  • Top
  • Right
  • Bottom
  • Left
  • Custom

The custom option would effectively be the same as the current 'Unlink' option and provide a dedicated control for each sides. In this case I think we can condense by arranging the controls into columns.

Here's a visual which (hopefully) describes things a bit better:

Screenshot 2023-03-22 at 12 16 32

As you can see the footprint of both single-side and unlinked control instances is significantly reduced.

Activity

  1. added
    [Feature] Design ToolsTools that impact the appearance of blocks both to expand the number of tools and improve the experi
    on Mar 22, 2023
  2. paaljoachim commented on Mar 22, 2023

    @paaljoachim
    Contributor

    Hey James.

    That is a very good idea! I like the compact view in the last mockup!
    The only thing that comes up is if the controls become too small to handle.
    It would be interesting to try out!

  3. moved this to Has issue in 6.3 Designon Mar 22, 2023
  4. moved this from Needs design to Needs feedback in 6.3 Designon Mar 22, 2023
  5. richtabor commented on Mar 23, 2023

    @richtabor
    Member

    I'm curious. What's the thinking on the chunkier tracks?

  6. richtabor commented on Mar 23, 2023

    @richtabor
    Member

    And for the columns arrangement, what're you thinking for when a custom value is used?

  7. jameskoster commented on Mar 23, 2023

    @jameskoster
    Author
  8. cbirdsong commented on Mar 23, 2023

    @cbirdsong

    It would really be good if a new design for the slider could solve the unset/inherit/default problem described in #43082 (comment). Would this design also look identical to "none" before it's been modified?

  9. cbirdsong commented on Mar 23, 2023

    @cbirdsong

    Separately and more focused on this specific issue, have you considered arranging them in a + shape to make it very clear what slider is associated with each side?

    Padding sliders arranged with top in the center, left and right next to each other, and bottom centered below that
    (Pardon my very quick rearrangement of the screenshot above, the spacing and alignment is definitely sloppy)

  10. jasmussen commented on Mar 24, 2023

    @jasmussen
  11. 20 remaining items

  12. aaronrobertshaw commented on May 16, 2023

    @aaronrobertshaw
    Contributor

    Thanks for the icons and feedback 👍

    I have a draft PR up in #50660. There's still a lot left to polish so take it with a grain of salt.

    It also still retains the linked/all sides view for the control. Mainly due to covering the potential for odd side support configurations on custom blocks such as ["top", "right", "bottom" ]. It also keeps the initial footprint to a minimum which seemed in the spirit of this issue but I'm happy to iterate from here.

    Other than that, I have two further questions;

    1. Do we still want to retain the hints similar to the old version of the control?
      • In the old control we would render a hint beside the label.
      • With the new design we don't necessarily have a label to render a hint beside.
    2. If we were to keep the linked/all sides view, should we omit the axial view if only one axis is supported?
      • If we have a sides configuration of ["top", "bottom"], the axial view ("Vertical") is almost the same as the all sides view.
      • The main difference is that the axial view has a duplicate vertical icon

    No doubt, I'll have further questions as we iterate but that's about all my brain can handle for today 🙂

  13. jameskoster commented on May 16, 2023

    @jameskoster
    ContributorAuthor

    For me, the hints aren't super useful and just add noise. So I'd be fine with losing them.

    If we were to keep the linked/all sides view, should we omit the axial view if only one axis is supported?

    Is the sides configuration already built into the control? It seems a bit strange to limit sides for which a user can add/edit padding 🤔 If it is, then yes it probably doesn't make sense to show the option(s) for disabled configs. Apologies if I am misunderstanding the question. FWIW I still lean towards omitting the linked/all sides view. It's quite rare to need equal vertical & horizontal padding.

  14. aaronrobertshaw commented on May 17, 2023

    @aaronrobertshaw
    Contributor

    For me, the hints aren't super useful and just add noise. So I'd be fine with losing them.

    👍 Sounds like a plan. I'll leave them out.

    Is the sides configuration already built into the control?

    That is correct. The ability to configure any supported sides from top, right, bottom, left, was added as far back as April 2021. It was extended shortly after that to allow axial sides (horizontal & vertical) to be supported in the block.json sides config.

    It seems a bit strange to limit sides for which a user can add/edit padding

    I agree. There are a couple of blocks that restrict padding to only the axial sides i.e. horizontal & vertical, no support for individual sides. The button block is the primary example there.

    It is possible for 3rd party blocks to have configured their sides however they wanted. So any subset of [ top, right, bottom, left, horizontal, vertical ]

    The other thing worth noting here is that this same approach to sides configuration applies to all spacing block supports and they all (margin, block gap etc) share this same spacing control.

    If it is, then yes it probably doesn't make sense to show the option(s) for disabled configs

    The current state of #50660 doesn't show any controls for disabled sides. The issue is when only one axial side is supported via ["top", "bottom"], the "linked" view is effectively the same as the "axial" view which would only be showing a single control as well.

    Screen.Recording.2023-05-17.at.7.08.36.pm.mp4

    Regarding the inclusion of the "linked" view, I kept it for the moment as noted to cover a sides configuration that doesn't neatly align with the horizontal and vertical axial views.

    A contrived example might be a 3rd party block, using an inner blocks template with a custom child block. It might have that custom child block styled to appear in the top-right corner and they wish to allow the configuration of margin for only the left and bottom sides. (I did say contrived 🙂). In such a situation, I don't think it makes sense to default to the "axial" view.

    We could default to the "custom" view containing all the separated controls. Would that be undermining the effort to reduce the footprint of this control? Or is it an edge case we can safely ignore for the time being?

    Left, Bottom Top, Bottom, Left
    Screen.Recording.2023-05-17.at.7.10.53.pm.mp4
    Screen.Recording.2023-05-17.at.7.11.56.pm.mp4

    I'm happy to iterate on #50660 however you'd like it. I can certainly remove the "linked" view, or we could only include it for those edge case configurations like [top, bottom, left] etc. where it might be more useful.

    Thanks for the guidance and direction on this one 🙇

  15. jameskoster commented on May 17, 2023

    @jameskoster
    ContributorAuthor

    We could default to the "custom" view containing all the separated controls.

    In your example, this makes the most sense to me. I don't think it undermines the "reduce the footprint" objective because only the editable sides would be represented, so in this case two controls. It does also feel a bit of an edge case that we can perhaps circle back to.

    Thanks for the diligence here, it's a tricky one!

  16. ciampo commented on May 17, 2023

    @ciampo
    Contributor

    I have a question that is tangential to this specific PR, but it came to mind while observing the current WIP: for languages with different writing directions (ie. RTL, or even top to bottom), how do we handle these margins? Ie. is "margin left" always applied to the left of the container, regardless of writing direction?

    Have we considered using a model similar to logical CSS properties so that our layouts are writing direction agnostic? This will interesting especially in the context of multi-language sites.

    (excuse my intermission, definitely not blocking for this issue).

  17. moved this from 🎨 Needs design to 🏗 In progress in Gutenberg Phase 2: Customizationon May 17, 2023
  18. moved this from Needs development to In progress in Polishon May 17, 2023
  19. aaronrobertshaw commented on May 18, 2023

    @aaronrobertshaw
    Contributor

    In your example, this makes the most sense to me.

    I've removed the linked view and the control now defaults to the axial view when available, single side view if that's all that's supported, and the custom view for edge case configurations or when individual sides have mixed values.

    The PR still needs some polishing but it is in a state where you can give it a run and get a feel for the new UX.

    Quick demo
    Screen.Recording.2023-05-18.at.5.23.20.pm.mp4

    how do we handle these margins? Ie. is "margin left" always applied to the left of the container, regardless of writing direction?

    At this stage, that's how the style engine maps the values to CSS styles, which follows the approach the block supports took originally.

    Have we considered using a model similar to logical CSS properties so that our layouts are writing direction agnostic? This will interesting especially in the context of multi-language sites.

    Good question. Long term, I'm expecting we will need to move to something like that.

    Updating the block supports and style engine to produce the correct styles with logical CSS properties should be pretty straightforward. Manipulating the control's UI to reflect the physical spacing might be a little more involved. I'd expect the style object to remain fairly consistent so with luck the trick would be applying appropriate labels and icons to the individual spacing sizes controls.

    This would be a great follow-up to explore so it can be stable before its need becomes more pressing.

  20. removed
    Needs DevReady for, and needs developer efforts
    on May 24, 2023
  21. moved this from 🏗 In progress to ✅ Done in Gutenberg Phase 2: Customizationon May 29, 2023
  22. moved this from In progress to Done in Polishon May 31, 2023
  23. moved this from Needs dev to Done in 6.3 Designon Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Feature] Design ToolsTools that impact the appearance of blocks both to expand the number of tools and improve the experi

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions