Skip to content
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

Button: update spacing support to use axial padding #33859

Merged
merged 10 commits into from Aug 12, 2021

Conversation

@stacimc
Copy link
Contributor

@stacimc stacimc commented Aug 3, 2021

Description

This is a follow up to #31774. This PR updates the spacing block supports to provide axial padding as an option. It also updates the Button block to use general and axial padding (as opposed to padding for each of the individual sides).

I added the padding support on Button recently in #31774, at which time it wasn't possible to enable axial selections via the block support. This PR is meant to be a relatively fast follow-up to address a suggestion to limit the controls to axial sides (anticipated to be the most common use case) until we see concrete requests for padding support on individual arbitrary sides (at which point we could easily go back).

In an example block.json:

supports: {
    spacing: {
        margin: [ 'top', 'bottom' ],
        padding: [ 'vertical' ]
    }
}

This block would support both margin and padding for the top and bottom sides. However the margin can be controlled for the top and bottom individually, while the padding UI will only display a 'vertical' control to update both sides at once.

There are a couple of things I'd like to call out for feedback:

  1. I've chosen to disallow configuring the spacing supports for a mix of individual and axial sides -- eg no configuring padding for vertical and left. I think this would lead to confusion with naming, setting sensible defaults, etc. I disallow this by logging a warning when an invalid configuration is detected, and disabling the feature. I'm not aware of and couldn't find any other examples of block support configuration errors, so would love feedback here.

  2. This PR makes use of the existing splitOnAxis feature of the BoxControl introduced in #32610. For the Button block, grouped 'horizontal' and 'vertical' controls will render when the controls are unlinked, as opposed to four individual controls. I want to call this out since the linking/unlinking for Button here is different compared to other blocks.

How has this been tested?

Test Button Block

  1. Check out this PR. Create a new post and insert a Button block.
  2. Open the Spacing controls in the Inspector Controls. The padding control should initially be linked (a single input controlling all sides). Test updating the padding for all sides.
  3. Click the button to unlink the controls. There should only be two inputs displayed, for horizontal and vertical sides respectively. Test changing each separately.
  4. Test that changes are persisted on the frontend.

Test Block Supports
Test configuring the support for all sides by default
Update button/block.json to enable padding for all sides by changing it to:

                "spacing": {
			"__experimentalSkipSerialization": true,
			"padding": true
		},

Test in the editor that all sides can be controlled individually when the controls are unlinked.

Test configuring arbitrary individual sides still works
Update button/block.json to enable padding for arbitrary sides:

    "padding": [ "top", "bottom", "left" ]

Test that only the supported sides are able to be controlled when the controls are unlinked.

Test that invalid mixes of axial and individual sides are not allowed
Update button/block.json to enable padding for an invalid mix of axial/individual sides:

    "padding": [ "vertical", "left" ]

Test that a warning is logged and the padding feature is disabled; UI should not display.

Test margin support
Add margin support to the button block and repeat all tests. You will need to make sure that your theme enables margin support for the button block in order to do this.

                "spacing": {
			"__experimentalSkipSerialization": true,
                       "padding": [ "horizontal", "vertical" ]
			"margin": [ "horizontal", "vertical" ]
		},

Screenshots

button-padding.mov

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
@github-actions
Copy link

@github-actions github-actions bot commented Aug 3, 2021

Size Change: +284 B (0%)

Total Size: 1.03 MB

Filename Size Change
build/block-editor/index.min.js 118 kB +165 B (0%)
build/block-library/index.min.js 146 kB +15 B (0%)
build/edit-site/index.min.js 25.9 kB +104 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 931 B
build/admin-manifest/index.min.js 1.09 kB
build/annotations/index.min.js 2.7 kB
build/api-fetch/index.min.js 2.19 kB
build/autop/index.min.js 2.08 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.21 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/style-rtl.css 13.9 kB
build/block-editor/style.css 13.9 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 474 B
build/block-library/blocks/button/editor.css 474 B
build/block-library/blocks/button/style-rtl.css 605 B
build/block-library/blocks/button/style.css 604 B
build/block-library/blocks/buttons/editor-rtl.css 315 B
build/block-library/blocks/buttons/editor.css 315 B
build/block-library/blocks/buttons/style-rtl.css 370 B
build/block-library/blocks/buttons/style.css 370 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 131 B
build/block-library/blocks/code/theme.css 131 B
build/block-library/blocks/columns/editor-rtl.css 194 B
build/block-library/blocks/columns/editor.css 193 B
build/block-library/blocks/columns/style-rtl.css 474 B
build/block-library/blocks/columns/style.css 475 B
build/block-library/blocks/cover/editor-rtl.css 666 B
build/block-library/blocks/cover/editor.css 670 B
build/block-library/blocks/cover/style-rtl.css 1.23 kB
build/block-library/blocks/cover/style.css 1.23 kB
build/block-library/blocks/embed/editor-rtl.css 488 B
build/block-library/blocks/embed/editor.css 488 B
build/block-library/blocks/embed/style-rtl.css 400 B
build/block-library/blocks/embed/style.css 400 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 707 B
build/block-library/blocks/gallery/editor.css 706 B
build/block-library/blocks/gallery/style-rtl.css 1.05 kB
build/block-library/blocks/gallery/style.css 1.05 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 93 B
build/block-library/blocks/group/theme.css 93 B
build/block-library/blocks/heading/editor-rtl.css 152 B
build/block-library/blocks/heading/editor.css 152 B
build/block-library/blocks/heading/style-rtl.css 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/home-link/style-rtl.css 247 B
build/block-library/blocks/home-link/style.css 247 B
build/block-library/blocks/html/editor-rtl.css 283 B
build/block-library/blocks/html/editor.css 284 B
build/block-library/blocks/image/editor-rtl.css 728 B
build/block-library/blocks/image/editor.css 728 B
build/block-library/blocks/image/style-rtl.css 482 B
build/block-library/blocks/image/style.css 487 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/list/style-rtl.css 63 B
build/block-library/blocks/list/style.css 63 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 488 B
build/block-library/blocks/media-text/style.css 485 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 474 B
build/block-library/blocks/navigation-link/editor.css 474 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation/editor-rtl.css 1.69 kB
build/block-library/blocks/navigation/editor.css 1.69 kB
build/block-library/blocks/navigation/style-rtl.css 1.65 kB
build/block-library/blocks/navigation/style.css 1.64 kB
build/block-library/blocks/navigation/view.min.js 2.52 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 310 B
build/block-library/blocks/page-list/editor.css 310 B
build/block-library/blocks/page-list/style-rtl.css 242 B
build/block-library/blocks/page-list/style.css 242 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 248 B
build/block-library/blocks/paragraph/style.css 248 B
build/block-library/blocks/post-author/editor-rtl.css 210 B
build/block-library/blocks/post-author/editor.css 210 B
build/block-library/blocks/post-author/style-rtl.css 182 B
build/block-library/blocks/post-author/style.css 181 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B
build/block-library/blocks/post-comments-form/style.css 140 B
build/block-library/blocks/post-comments/style-rtl.css 360 B
build/block-library/blocks/post-comments/style.css 359 B
build/block-library/blocks/post-content/editor-rtl.css 138 B
build/block-library/blocks/post-content/editor.css 138 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 412 B
build/block-library/blocks/post-featured-image/editor.css 412 B
build/block-library/blocks/post-featured-image/style-rtl.css 143 B
build/block-library/blocks/post-featured-image/style.css 143 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 378 B
build/block-library/blocks/post-template/style.css 379 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 60 B
build/block-library/blocks/post-title/style.css 60 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 361 B
build/block-library/blocks/pullquote/style.css 360 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B
build/block-library/blocks/query-pagination/editor.css 262 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B
build/block-library/blocks/query-pagination/style.css 168 B
build/block-library/blocks/query-title/editor-rtl.css 85 B
build/block-library/blocks/query-title/editor.css 85 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 169 B
build/block-library/blocks/quote/style.css 169 B
build/block-library/blocks/quote/theme-rtl.css 220 B
build/block-library/blocks/quote/theme.css 222 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 374 B
build/block-library/blocks/search/style.css 375 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 250 B
build/block-library/blocks/separator/style.css 250 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 462 B
build/block-library/blocks/site-logo/editor.css 464 B
build/block-library/blocks/site-logo/style-rtl.css 153 B
build/block-library/blocks/site-logo/style.css 153 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 165 B
build/block-library/blocks/social-link/editor.css 165 B
build/block-library/blocks/social-links/editor-rtl.css 812 B
build/block-library/blocks/social-links/editor.css 811 B
build/block-library/blocks/social-links/style-rtl.css 1.33 kB
build/block-library/blocks/social-links/style.css 1.33 kB
build/block-library/blocks/spacer/editor-rtl.css 307 B
build/block-library/blocks/spacer/editor.css 307 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 636 B
build/block-library/blocks/template-part/editor.css 635 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/editor-rtl.css 90 B
build/block-library/blocks/term-description/editor.css 90 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 832 B
build/block-library/common.css 830 B
build/block-library/editor-rtl.css 9.38 kB
build/block-library/editor.css 9.37 kB
build/block-library/reset-rtl.css 527 B
build/block-library/reset.css 527 B
build/block-library/style-rtl.css 9.78 kB
build/block-library/style.css 9.79 kB
build/block-library/theme-rtl.css 688 B
build/block-library/theme.css 692 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 47 kB
build/components/index.min.js 209 kB
build/components/style-rtl.css 15.7 kB
build/components/style.css 15.8 kB
build/compose/index.min.js 10.2 kB
build/core-data/index.min.js 12.3 kB
build/customize-widgets/index.min.js 10.4 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 614 B
build/data/index.min.js 7.03 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 428 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.53 kB
build/edit-navigation/index.min.js 13.4 kB
build/edit-navigation/style-rtl.css 3.1 kB
build/edit-navigation/style.css 3.1 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 28.4 kB
build/edit-post/style-rtl.css 7.18 kB
build/edit-post/style.css 7.17 kB
build/edit-site/style-rtl.css 5.01 kB
build/edit-site/style.css 5.01 kB
build/edit-widgets/index.min.js 15.9 kB
build/edit-widgets/style-rtl.css 4.01 kB
build/edit-widgets/style.css 4.02 kB
build/editor/index.min.js 37.5 kB
build/editor/style-rtl.css 3.92 kB
build/editor/style.css 3.91 kB
build/element/index.min.js 3.16 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 5.36 kB
build/format-library/style-rtl.css 668 B
build/format-library/style.css 669 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.59 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.49 kB
build/keycodes/index.min.js 1.25 kB
build/list-reusable-blocks/index.min.js 1.85 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.88 kB
build/notices/index.min.js 845 B
build/nux/index.min.js 2.03 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.83 kB
build/primitives/index.min.js 921 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.63 kB
build/reusable-blocks/index.min.js 2.28 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.5 kB
build/server-side-render/index.min.js 1.32 kB
build/shortcode/index.min.js 1.48 kB
build/token-list/index.min.js 562 B
build/url/index.min.js 1.72 kB
build/viewport/index.min.js 1.02 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 6.27 kB
build/widgets/style-rtl.css 1.04 kB
build/widgets/style.css 1.04 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@stacimc stacimc changed the title Update/axial padding support for button [Button]: add axial padding support Aug 3, 2021
@stacimc stacimc self-assigned this Aug 3, 2021
@stacimc stacimc changed the title [Button]: add axial padding support Button: update spacing support to use axial padding Aug 4, 2021
@stacimc stacimc marked this pull request as ready for review Aug 4, 2021
@stacimc
Copy link
Contributor Author

@stacimc stacimc commented Aug 4, 2021

Pinging @jasmussen as this PR relates to your concerns here: #32610 (comment)

I was discussing this a little with @andrewserong and @aaronrobertshaw, and considering potential issues with the Button block behaving differently when you unlink the sides in the padding controls compared to other blocks. One thought is that we could get rid of the linking/unlinking behavior for Button; so, only display the axial controls with no option to link/unlink. This prevents any frustration that might be caused by expanding the box control and perceiving missing options/less granularity than they may see in the padding controls for other blocks.

I'm unsure if that's necessary, or if it's consistent with other use cases for axial controls. Gap, for example, seems like it would benefit from having both general and axial spacing.

@stacimc
Copy link
Contributor Author

@stacimc stacimc commented Aug 4, 2021

Also pinging @mtias since this is a follow-up on your request here: #31774 (comment) :)

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Aug 5, 2021

Thanks for working on this! Here's before:

before

And here's after:

after

On the one hand, it's nice to be able to control both sides on an axis, and is very probably what you want most of the time.

On the other hand, this now becomes impossible:

Screenshot 2021-08-05 at 08 55 08

I would consider it an edgecase, but it's also always important to be aware of the opportunity cost: which creative designs are we making impossible by our changes, even if well-intended? Additionally, the axial split controls are surfaced after you untoggle the "link" button, meaning you've already made a choice to surface the advanced padding controls.

In this case, I tend to think that axial padding support is possibly something we can implement in a more visual way such as #33221. In that interface we might enable axial resizing when holding Alt and dragging. Taking that a step further, we might even support Alt + dragging on the input control to do the same in the 4-split input controls.

Axial controls feel the most potent when affecting interfaces that are already technically locked in a similar way, such as column blocks where the axes control the gap property between them. Or in cases where we are absolutely sure we want to limit the configuration. In this case, I'm not convinced. But it's also not a strong opinion, and I'm happy to defer.

Nice work!

@stacimc
Copy link
Contributor Author

@stacimc stacimc commented Aug 5, 2021

On the one hand, it's nice to be able to control both sides on an axis, and is very probably what you want most of the time.
On the other hand, this now becomes impossible:

For context (description updated now), I added the padding support on Button very recently in #31774, at which time it wasn't possible to enable axial selections via the block support. This is meant to be a relatively fast follow-up to address a suggestion to limit the controls to axial sides until we see concrete requests for padding support on individual arbitrary sides (at which point we could easily go back).

My take on this is that controlling top/bottom or left/right padding as pairs is likely what users want most of the time, and is a little cumbersome using the four individual side controls. It's possible by holding down the Alt key as you point out, but not obvious, and seems a little bit like requiring a "power feature" to optimize the most common use case. The visual controls in #33221 look fantastic, but as proposed require a key combination to access and also seem to me like a bit of a power feature.

I do worry about making it impossible to achieve those edge cases with mismatched padding on axial sides -- maybe we get the best of both worlds by limiting the Inspector Controls to the axial sides, and allowing individual side padding via the visual controls in the future? This makes the common use case very easy via Inspector Controls but allows finer customization via the more advanced/"power feature".

Additionally, the axial split controls are surfaced after you untoggle the "link" button, meaning you've already made a choice to surface the advanced padding controls.

+1 What do you think about removing the linking/unlinking here? So specifically for Button, we display the axial controls by default with no link/unlink button. The obvious downside is we lose the ability to change general padding for all sides very quickly (you can obviously still individually update the two inputs). This feels less cumbersome to me than updating the four individual inputs.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Aug 6, 2021

+1 What do you think about removing the linking/unlinking here? So specifically for Button, we display the axial controls by default with no link/unlink button. The obvious downside is we lose the ability to change general padding for all sides very quickly (you can obviously still individually update the two inputs). This feels less cumbersome to me than updating the four individual inputs.

That's an interesting thought!

With that in mind, we might actually want to just try this PR as is, and if the use case I described comes back to haunt us, we can explore that.

👍 👍

@andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Aug 6, 2021

@stacimc I haven't had a chance to test this properly yet, but nice work hooking into the axial controls! I think we might need to also update the global styles spacing panel to ensure that the filterValuesBySides function sets filteredValues correctly — at the moment it looks like the function expects each of the sides to be left, top, right, bottom, so if the custom sides are horizontal or vertical, we might need special handling in that function to pass those values along.

Here's where the function lives:

https://github.com/wordpress/gutenberg/blob/trunk/packages/edit-site/src/components/sidebar/spacing-panel.js#L36-L36

We might be able to borrow a bit of the logic from the axial-input-controls to keep it consistent?

@stacimc
Copy link
Contributor Author

@stacimc stacimc commented Aug 6, 2021

I think we might need to also update the global styles spacing panel

Good catch, thank you! I will take a look at this :)

@andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Aug 11, 2021

This code change is looking good to me @stacimc, and nice inclusion of the validity check. Looks like this just needs a rebase now that the ToolsPanel is in, but I’m happy to give this another look over and test once it’s ready!

stacimc added 10 commits Aug 3, 2021
If a spacing support is configured with an invalid mix of axial and
individual sides, log a warning and disable the feature. If only
one feature is invalidly configured, this does not affect the other;
eg if padding is configured incorrectly but margin is not, padding
is disabled but margins will continue to work.
Previously the hook was only used if the feature was known to be
supported. Now that it is used in checking the spacing configuration,
it is possible for `support` to be undefined here.
@stacimc stacimc force-pushed the update/axial-padding-support-for-button branch from 4add752 to fddeb7e Aug 11, 2021
@stacimc
Copy link
Contributor Author

@stacimc stacimc commented Aug 11, 2021

This has been updated to include the changes from the new Dimensions panel (#32392). I've also made padding a default control for Button.

Copy link
Contributor

@andrewserong andrewserong left a comment

Thanks for the work here @stacimc, this looks great to me!

Axial controls are working correctly for me within the post editor
Axial controls are working correctly for me within the site editor
Specifying individual sides in the block.json file works as expected
Specifying axial sides in the block.json file works as expected
Console warning for a support including both axial and arbitrary sides makes sense to me and the UI for the support is hidden, but the existing block doesn't throw a validation

image

This all LGTM, so I've given it the , but it'd be great to get a couple more pairs of 👀 on this, too, to see what other folks think about the approach for checking that the support is valid. I was also going to suggest using the plural of axis instead of "axial sides" but given that the word looks the same as the plural for the word "axe", I think "axial sides" is a better trade-off 😀

@apeatling
Copy link
Contributor

@apeatling apeatling commented Aug 12, 2021

Ran through every check and this worked as designed. 👍

I think the notice in the console is standard for letting developers know when something is deprecated or not implemented as expected, so this seems like a good place to me.

I think the more visual representation of padding on the canvas that @jasmussen linked to could be followed up on after this initial round of tools work is completed, as we continue to refine the tools and the UI we are adding.

@apeatling apeatling merged commit 99ef4c3 into trunk Aug 12, 2021
19 of 20 checks passed
19 of 20 checks passed
@github-actions
test (12.2, gutenberg-editor-initial-html, 14) test (12.2, gutenberg-editor-initial-html, 14)
Details
@github-actions
Compute current and next stable release branches
Details
@github-actions
test
Details
@github-actions
Check (14)
Details
@github-actions
Checks (12)
Details
@github-actions
Admin - 1 Admin - 1
Details
@github-actions
Run performance tests
Details
@github-actions
pull-request-automation (14)
Details
@github-actions
JavaScript (12)
Details
@github-actions
Checks (14)
Details
@github-actions
Admin - 2 Admin - 2
Details
@github-actions
JavaScript (14)
Details
@github-actions
Admin - 3 Admin - 3
Details
@github-actions
Admin - 4 Admin - 4
Details
@github-actions
Bump version
Details
@github-actions
Build Release Artifact
Details
@github-actions
Mobile
Details
@github-actions
Create Release Draft and Attach Asset
Details
@apeatling apeatling deleted the update/axial-padding-support-for-button branch Aug 12, 2021
@github-actions github-actions bot added this to the Gutenberg 11.4 milestone Aug 12, 2021
ramonjd added a commit that referenced this pull request Aug 13, 2021
* Add support for axial sides to padding block support

* Update button to support general and axial padding only

* Update docs

* Enable axial support for margin block support

* Warn against invalid sides configuration and disable support

If a spacing support is configured with an invalid mix of axial and
individual sides, log a warning and disable the feature. If only
one feature is invalidly configured, this does not affect the other;
eg if padding is configured incorrectly but margin is not, padding
is disabled but margins will continue to work.

* Update docs

* Clearer hook name

* Check that support is defined in useCustomSides

Previously the hook was only used if the feature was known to be
supported. Now that it is used in checking the spacing configuration,
it is possible for `support` to be undefined here.

* Update global styles panel

* Make padding a default control for the button block
@mtias
Copy link
Contributor

@mtias mtias commented Aug 13, 2021

Thanks for this follow up! This is a much better default.

On the other hand, this now becomes impossible

@jasmussen I'm fine with this not being possible. It can always be added later if there's a strong need for it. Right now, allowing arbitrary values on Button feels like it will invariably produce not great results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants