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

Block Support: Add width block support feature #32502

Closed

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented Jun 8, 2021

Related:

Depends on:

Description

  • Adds width block support and includes in new Dimensions panel.
  • Adds new segmented width control

How has this been tested?

Style.js test:
npm run test-unit:watch packages/block-editor/src/hooks/test/style.js

Manual Test Instructions

  1. Checkout this PR and build
  2. Enable custom dimensions support including height, width, padding and margin - theme.json gist
  3. Enable dimensions block support for Group block - block.json gist
  4. Create a post, switch to code editor view and paste in the snippet of block code below:
<!-- wp:group {"backgroundColor":"gray"} -->
<div class="wp-block-group has-gray-background-color has-background"><!-- wp:group {"backgroundColor":"white"} -->
<div class="wp-block-group has-white-background-color has-background"></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
  1. Switch back to the visual editor and select the white inner group block
  2. Ensure dimensions panel appears in the sidebar
  3. Open the dimension panel's more menu and toggle on the width control
  4. Adjust the width and confirm the block's width gets adjusted. Inspect element in dev tools to confirm CSS style
  5. Click on the edit button beside the preset percentage widths and configure an explicit width for the group
  6. Test clearing the width by toggling off the width control from the panel's ellipsis menu
  7. Save post and view on the frontend. The width style should be applied correctly
  8. Repeat the process for a dynamic block, e.g. site title, ensuring correct styles on the frontend
  9. Update your block.json you've been testing with to set the width block support feature flag to true instead of "segmented". Repeat the test process this time ensuring the width control is a standard UnitControl

Screenshots

WidthSupport-Latest

Possible Next Steps

  • Possibly add min/max width support alongside this?

Types of changes

New feature.

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).

@aaronrobertshaw aaronrobertshaw self-assigned this Jun 8, 2021
@aaronrobertshaw aaronrobertshaw added [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Enhancement A suggestion for improvement. labels Jun 8, 2021
@github-actions
Copy link

github-actions bot commented Jun 8, 2021

Size Change: +765 B (0%)

Total Size: 1.15 MB

Filename Size Change
build/block-editor/index.min.js 144 kB +471 B (0%)
build/block-editor/style-rtl.css 14.9 kB +100 B (+1%)
build/block-editor/style.css 14.9 kB +101 B (+1%)
build/block-library/index.min.js 168 kB +16 B (0%)
build/blocks/index.min.js 46.4 kB +14 B (0%)
build/components/index.min.js 215 kB +2 B (0%)
build/edit-site/index.min.js 42.2 kB +61 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 993 B
build/admin-manifest/index.min.js 1.24 kB
build/annotations/index.min.js 2.77 kB
build/api-fetch/index.min.js 2.25 kB
build/autop/index.min.js 2.15 kB
build/blob/index.min.js 487 B
build/block-directory/index.min.js 6.49 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
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 150 B
build/block-library/blocks/audio/editor.css 150 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 470 B
build/block-library/blocks/button/editor.css 470 B
build/block-library/blocks/button/style-rtl.css 560 B
build/block-library/blocks/button/style.css 560 B
build/block-library/blocks/buttons/editor-rtl.css 292 B
build/block-library/blocks/buttons/editor.css 292 B
build/block-library/blocks/buttons/style-rtl.css 275 B
build/block-library/blocks/buttons/style.css 275 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 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 406 B
build/block-library/blocks/columns/style.css 406 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-template/style-rtl.css 127 B
build/block-library/blocks/comment-template/style.css 127 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-query-loop/editor-rtl.css 95 B
build/block-library/blocks/comments-query-loop/editor.css 95 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.55 kB
build/block-library/blocks/cover/style.css 1.55 kB
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 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 353 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 965 B
build/block-library/blocks/gallery/editor.css 967 B
build/block-library/blocks/gallery/style-rtl.css 1.61 kB
build/block-library/blocks/gallery/style.css 1.61 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 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 518 B
build/block-library/blocks/image/style.css 523 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 199 B
build/block-library/blocks/latest-posts/editor.css 198 B
build/block-library/blocks/latest-posts/style-rtl.css 447 B
build/block-library/blocks/latest-posts/style.css 446 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 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 493 B
build/block-library/blocks/media-text/style.css 490 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 649 B
build/block-library/blocks/navigation-link/editor.css 650 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-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/view.min.js 375 B
build/block-library/blocks/navigation/editor-rtl.css 1.98 kB
build/block-library/blocks/navigation/editor.css 1.99 kB
build/block-library/blocks/navigation/style-rtl.css 1.89 kB
build/block-library/blocks/navigation/style.css 1.88 kB
build/block-library/blocks/navigation/view.min.js 2.85 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 401 B
build/block-library/blocks/page-list/editor.css 402 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 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 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 446 B
build/block-library/blocks/post-comments-form/style.css 446 B
build/block-library/blocks/post-comments/style-rtl.css 521 B
build/block-library/blocks/post-comments/style.css 521 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 721 B
build/block-library/blocks/post-featured-image/editor.css 721 B
build/block-library/blocks/post-featured-image/style-rtl.css 153 B
build/block-library/blocks/post-featured-image/style.css 153 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 323 B
build/block-library/blocks/post-template/style.css 323 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 80 B
build/block-library/blocks/post-title/style.css 80 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 389 B
build/block-library/blocks/pullquote/style.css 388 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 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 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 201 B
build/block-library/blocks/quote/style.css 201 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 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 397 B
build/block-library/blocks/search/style.css 398 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 233 B
build/block-library/blocks/separator/style.css 233 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 744 B
build/block-library/blocks/site-logo/editor.css 744 B
build/block-library/blocks/site-logo/style-rtl.css 181 B
build/block-library/blocks/site-logo/style.css 181 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 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.37 kB
build/block-library/blocks/social-links/style.css 1.36 kB
build/block-library/blocks/spacer/editor-rtl.css 332 B
build/block-library/blocks/spacer/editor.css 332 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 214 B
build/block-library/blocks/tag-cloud/style.css 215 B
build/block-library/blocks/template-part/editor-rtl.css 560 B
build/block-library/blocks/template-part/editor.css 559 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/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 921 B
build/block-library/common.css 919 B
build/block-library/editor-rtl.css 10.1 kB
build/block-library/editor.css 10.1 kB
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/style-rtl.css 11.3 kB
build/block-library/style.css 11.3 kB
build/block-library/theme-rtl.css 672 B
build/block-library/theme.css 676 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/components/style-rtl.css 15.5 kB
build/components/style.css 15.5 kB
build/compose/index.min.js 11.2 kB
build/core-data/index.min.js 14 kB
build/customize-widgets/index.min.js 11.4 kB
build/customize-widgets/style-rtl.css 1.49 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 663 B
build/data/index.min.js 7.45 kB
build/date/index.min.js 31.9 kB
build/deprecated/index.min.js 518 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.53 kB
build/edit-navigation/index.min.js 16.2 kB
build/edit-navigation/style-rtl.css 3.76 kB
build/edit-navigation/style.css 3.76 kB
build/edit-post/classic-rtl.css 546 B
build/edit-post/classic.css 547 B
build/edit-post/index.min.js 29.9 kB
build/edit-post/style-rtl.css 7.19 kB
build/edit-post/style.css 7.18 kB
build/edit-site/style-rtl.css 7.23 kB
build/edit-site/style.css 7.22 kB
build/edit-widgets/index.min.js 16.7 kB
build/edit-widgets/style-rtl.css 4.17 kB
build/edit-widgets/style.css 4.17 kB
build/editor/index.min.js 38.5 kB
build/editor/style-rtl.css 3.71 kB
build/editor/style.css 3.71 kB
build/element/index.min.js 3.32 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 6.62 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.66 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.79 kB
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.83 kB
build/keycodes/index.min.js 1.41 kB
build/list-reusable-blocks/index.min.js 1.75 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.94 kB
build/notices/index.min.js 957 B
build/nux/index.min.js 2.12 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.98 kB
build/primitives/index.min.js 949 B
build/priority-queue/index.min.js 611 B
build/react-i18n/index.min.js 704 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.69 kB
build/reusable-blocks/index.min.js 2.24 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 11.1 kB
build/server-side-render/index.min.js 1.61 kB
build/shortcode/index.min.js 1.52 kB
build/token-list/index.min.js 668 B
build/url/index.min.js 1.92 kB
build/viewport/index.min.js 1.08 kB
build/warning/index.min.js 280 B
build/widgets/index.min.js 7.18 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.07 kB

compressed-size-action

@jasmussen
Copy link
Contributor

This is cool to see, thank you for work on this. Going back to #27331, the design there shows a different width toggle:

I understand that there will be cases where we need precise width control. But arguably, and the reason for that initial design, most of the time you should be using one of the theme-defined widths, such as default, wide, or full-wide. By being default/wide and full-wide, the controls in the sidebar are also aware of what you might have set in the block toolbar, rather than potentially conflict with them (such as choosing full-wide in the block toolbar, and 20px in the inspector).

We almost certainly want the fine-grained width-control for some blocks, such as Button. But probably not group? Or perhaps we need an improved UI that enables both? But in any case, that makes it a bit harder to land this one.

@aaronrobertshaw aaronrobertshaw added the [Status] In Progress Tracking issues with work in progress label Jun 8, 2021
@aaronrobertshaw
Copy link
Contributor Author

Going back to #27331, the design there shows a different width toggle:

I'll update this. I got a bit of tunnel vision after adding the initial height block support PR and worrying about how these controls would play within the new block support panel (Dimensions in this case). I've added the "In Progress" label to this for the time being.

We almost certainly want the fine-grained width-control for some blocks, such as Button. But probably not group? Or perhaps we need an improved UI that enables both? But in any case, that makes it a bit harder to land this one.

The group block was only used to test as it is a simple block. While updating this I'll see what options we might have via the block support flags to perhaps opt in to varying levels of width support. Simply opting in might give the segmented control. Setting the support flag to "custom" or something might then allow for the block to be given a UnitControl for that fine-grained control.

@aaronrobertshaw aaronrobertshaw marked this pull request as draft June 8, 2021 08:18
@aaronrobertshaw
Copy link
Contributor Author

@jasmussen I've had a chance to revisit this one today however I am struggling to understand how it is supposed to work based on the animated GIF and your previous comment. I didn't find any real answers in #27331 or #28356 either so I must be missing something.

My thoughts around the mock up for the width control include:

  • It looks like it has just been mislabelled width instead of alignment ( I realise that other mockups include a dropdown for the alignment support options)
  • I understand that a block's alignment can impact on it's width. I'm trying to understand how overlapping the width control with the alignment's helps. Especially the reuse of icons.
  • Would both the "wide" and "full" buttons from that segmented control actually just be setting 100% width? The alignment support applies a max or min width I believe.
  • What would the first button in the segmented control do? Does it set width to auto or 50% like the icon visually indicates?
  • I can see a lot of users being confused by what that width control is doing. They'll toggle the buttons on and off, then be frustrated that they can't actually control the width as the presence of a width control would indicate.
  • Would it not be better for the width controls to update to a meaningful value if the alignment changes to a selection that does impact the block's width? For example, if wide or full alignment is selected then the width is set to 100% or cleared and disabled/hidden.

In short, my current thoughts boil down to:

  1. What is the segmented control actually to achieve, what width values can be set via it?
  2. How can we reduce the confusion between it and the alignment support?
  3. Can we proceed with the initial width support proposed here for explicit widths? It can be used for those blocks that need explicit control and not opted into for blocks that we wish to provide some refined segmented control for?

Thanks in advance for the help getting up to speed on this one 🙏

@jasmussen
Copy link
Contributor

It looks like it has just been mislabelled width instead of alignment ( I realise that other mockups include a dropdown for the alignment support options)

It's a bit forward looking and needs a few other pieces in place, so definitely consider it a mockup more than a fully formed thought. In fact there are a few mockups that go in different directions for exactly the reasons you outline.

But to respond specifically around the alignments/widths mockup, that was intentional enough in that it acknowledges explicit horizontal pixel widths as something you should rarely if ever need for most blocks, as they very easily break responsiveness. The alternative are "width toggles" like wide and fullwide, as shown as a width "alignment".

There's another mockup that embraces it as an "alignment", but makes it a dropdown instead, like so:

Frame 251

But even that still needs a bit of thought, with some conversations suggesting we separate the actual alignments from the width based ones, and call those "Positions" instead:

Frame 252

More high level, those designs assume a dimensions panel that is contextual to some of the larger container blocks, like Cover or Group being selected. For other blocks, such as Button or Search, those "positions"/alignments would not make sense, and we'd likely want to end up with something closer to what we have today, with a segmented control featuring shortcuts to 25%/50%/75%/100% sizes. The balance in the following mockup isn't right — the pixels need massaging, maybe we want to show primarily the segmented control but make explicit values available in a toggle similar to individual paddings? But to convey the point, it's this general thought:

Sidebar

So my previous comment was more to convey that the Dimensions panel needs to be a bit more contextually aware, offering some affordances only to blocks like Search or Button, and alignment affordances to others. Since this PR targets the group, that's why I brought it up. But given we'll almost certainly still need the width control (even if not the height control) for the Button (singular) block, perhaps that's the best place to start?

If it is specifically destined for the group, we'll need to advance the designs a bit, and today is a bit tricky for me on that front, but I can probably find some time next week.

@aaronrobertshaw
Copy link
Contributor Author

Thank you for the explanations, it's becoming a little clearer 🙇

It's a bit forward looking and needs a few other pieces in place, so definitely consider it a mockup more than a fully formed thought.

It sounds like we need to iterate on the designs first before we can go much further down the path of a segmented control.

But to respond specifically around the alignments/widths mockup, that was intentional enough in that it acknowledges explicit horizontal pixel widths as something you should rarely if ever need for most blocks

Would explicit percentage widths not be perhaps desirable in some cases?

The alternative are "width toggles" like wide and fullwide, as shown as a width "alignment".

If these toggles overlap with the align wide and fullwide, they are the same effective width ( 100% ) while the alignment styles set a max width based on the layout. So this still confuses me. Why offer them if they do the same thing and are essentially what the default block width would be without any "width support"?

There's another mockup that embraces it as an "alignment", but makes it a dropdown instead, like so:

Ok, I interpreted this mockup as only including the separate alignment support, not width. I didn't realise they were supposed to be one and the same in this mockup.

But even that still needs a bit of thought, with some conversations suggesting we separate the actual alignments from the width based ones, and call those "Positions" instead:

I'd absolutely vote for separating them.

maybe we want to show primarily the segmented control but make explicit values available in a toggle similar to individual paddings?

This is something concrete that I could update the width control with in this PR. Do you think it is worth the time doing that now or should I hold off for any further design iterations/decisions?

Since this PR targets the group, that's why I brought it up. But given we'll almost certainly still need the width control (even if not the height control) for the Button (singular) block, perhaps that's the best place to start?

This PR doesn't actually target the Group block. I simply used it as a block to test with as it's generally a very simple block.

This width control will only be included within the Dimensions panel for blocks that opt into the width block support. If it doesn't make sense for the Group block, we don't opt in for it. If it does make sense for a Button, great, we opt in and so on. Same goes for the height support etc.

If it helps I can rewrite the testing instructions and update the demo GIF to revolve around the individual button block?

@jasmussen
Copy link
Contributor

It sounds like we need to iterate on the designs first before we can go much further down the path of a segmented control.

Cool, I'll find some time next week.

If these toggles overlap with the align wide and fullwide, they are the same effective width ( 100% ) while the alignment styles set a max width based on the layout. So this still confuses me. Why offer them if they do the same thing and are essentially what the default block width would be without any "width support"?

These toggles in the inspector would be the same as those in the toolbar. But in the mockups they are included because they are conceptually related to dimensions. Omitting them from dimensions because they are in the block toolbar already might be confusing.

In this case, I think of the block toolbar as a shortcut. You can see how that works with the Cover block "full height" option, which when toggled simply sets a 100vh height:

cover

You can see the connection between the two. That's also the key bit about potentially including such alignments in the inspector: wide and fullwide likely need to unset any explicit widths you might have set, because they take precedence. When you see the width becoming unset as you toggle one of those alignments (perhaps the entire widht panel graying out) it might make for a more obvious user experience.

This is part of what needs to be made clearer in the mockups, bug hopefully this comment can set the stage.

Would explicit percentage widths not be perhaps desirable in some cases?

Yes, Button does that and it's working well, so we'd at least want it as a default for those.

We may also want it for the bigger blocks, but we need to find a balance of prominence in the sidebar that naturally leads towards good choices by the user. It's very easy for someone to set a specific width of their block, looking at a desktop interface, and not realizing that width just broke the responsiveness of their site.

Perhaps that balance is showing alignments by default (whatever we call them), and hiding explicit width in the progressive menu. That would at least enable it for patterns and power users.

This is something concrete that I could update the width control with in this PR. Do you think it is worth the time doing that now or should I hold off for any further design iterations/decisions?

Let me see if I can take a quick stab at an overall doodle.

This width control will only be included within the Dimensions panel for blocks that opt into the width block support. If it doesn't make sense for the Group block, we don't opt in for it. If it does make sense for a Button, great, we opt in and so on. Same goes for the height support etc.

👍 👍

@jasmussen
Copy link
Contributor

jasmussen commented Jun 18, 2021

Here's a thought:

Padding and width

Inspired by the padding control, there could a default and an advanced view for the width control. By default, it's just shortcuts to useful values such as 25+100%. Click the edit button and the value becomes directly editable.

I'd appreciate a quick sanity check, perhaps @critterverse @javierarce @kjellr? It would be primarily an upgrade to this interface for the Button block:

Screenshot 2021-06-18 at 09 29 10

— but perhaps it could also be a more general Width control you could toggle on for the larger blocks, as discussed in this thread.

Edit: To clarify, this would not be a replacement for all width controls, but be in addition to, something like a "Segmented width control". For something like an Image, we'd still almost certainly need the basic control:

Image

@kjellr
Copy link
Contributor

kjellr commented Jun 18, 2021

Screen Shot 2021-06-18 at 11 03 28 AM

I like this. I'm not sure it's a totally clear parallel to the padding control though. For the padding control, you're splitting a value into four sub-values, whereas in the font-size and width controls, you're overriding the preset options. Your mockup feels more akin to the font size control:

Screen Shot 2021-06-18 at 10 58 27 AM

... but more nicely done. 🙂

(As an aside, in the padding mockup from #27331 I'm not sure folks will know to click on the padding icon, but your width mockup doesn't have that issue.)

@aaronrobertshaw
Copy link
Contributor Author

The proposed segmented width control looks great! ✨

I'll work on a prototype for it in this PR along with a means to choose which type of width control make sense when opting into the width block support.

Edit: To clarify, this would not be a replacement for all width controls, but be in addition to, something like a "Segmented width control". For something like an Image, we'd still almost certainly need the basic control:

My current thinking is that the feature flag for the block support would accept a couple of different values rather than only a boolean. If it is set to true or "basic" then it will display a standard UnitControl. If it is set to "segmented" then it will display this new control.

These toggles in the inspector would be the same as those in the toolbar.

Ok, so this means that the block toolbar controls are alignment block support controls and so to are the controls in the inspector.

This is where I think I've failed to communicate the confusion I've had. Previous descriptions and the mockup labelled alignment controls as width controls leading me to believe we needed to be overlapping their functionality.

My question about omitting options from the width block support controls was to remove some of that overlap thinking that the alignment block support controls would cover those elsewhere in the dimensions panel. Whether that was in a segmented control or the proposed dropdown.

You can see the connection between the two.

If the alignment block support adds controls to the dimensions panel as mentioned above, the inspector controls there would inherently match or be "connected" to the alignment options in the block toolbar as they'd both use the same block attribute.


My current understanding that I'll move forward with is:

  • Alignment and width block support are separate and different
  • The one exception to the above is that the width block support value would be cleared if align wide or full gets set
  • The controls for alignment and width block supports are separate
  • This is the simplest, cleanest, and, easiest approach to move forward with that can be iterated on if desired

If the above is correct, then all that is required on this PR is to:

  • add the new proposed width control (the one with preset % widths and toggle to switch to UnitControl + slider)
  • allow selection of the type of width control to be displayed when opting into block support

@jasmussen
Copy link
Contributor

My reason for thinking this approach of two width controls can work is that:

  • For Button blocks and others, we'll still want those uniform percentage width shortcuts, as they don't break responsiveness
  • It would be nice to also offer advanced control of the width, but with intentionally reduced prominence
  • We will still want explicit width/height controls for Images, side by side as is a custom, for blocks like Image

That's the primary problem we want to solve.

The thing about the design I'd like to still noodle on Kjell brings up. I'd like a stronger pattern for this type of toggling between basic and advanced, I'm not sure the edit button is right. I'm not sure we want a slider for the width. I'd love to find a pattern that is more easily scalable to other controls that might swap between basic and advanced like this. So I think we probably want this, but I'd also love a small sanity check by @mtias if he has time.

@aaronrobertshaw
Copy link
Contributor Author

I've created a prototype for the proposed width control as part of this PR.

The width block support now allows for opting into this new control in place of a standard UnitControl via the block.json file. This means we could use a standard width control for an image and the new control for the button etc.

I'm not sure we want a slider for the width

I think you are right here, the slider makes sense when we have more concrete boundaries like 0 and 100 for percentage widths. Things get more complicated when using non-percentage units, blocks having custom layouts of varying widths, be nested to various levels etc.

The prototype has a RangeControl slider at the moment. It can easily be removed if no longer desired.

With Slider Without Slider
WidthControl WidthControl2

@aaronrobertshaw
Copy link
Contributor Author

In case it aids further reasoning about the width control and width support I have a separate PR trialling adding the width block support and new control to the button block. #32878

@jasmussen
Copy link
Contributor

Thanks for your patience. I'm getting some notices running this branch, probably a result of my local env (Notice: register_block_type_from_metadata() was called incorrectly. Block "core/paragraph" is declaring lineHeight support in block.json file under supports.lineHeight), so I can only look at your GIFs.

And from what I can see, I think it's worth trying:

  • We need a custom width panel for the image.
  • We need a "shortcut" width panel for Button.
  • It'd be nice to be able to switch from the latter to the former.

As for next steps, outside of a good code review:

My biggest gotcha with this one is that when you click the edit icon to "unlock", you have to "tab backwards" to set focus in the width panel.

@aaronrobertshaw
Copy link
Contributor Author

I'm getting some notices running this branch, probably a result of my local env

I've started fresh, checking out this branch, building it, then following through the test setup as per PR description (steps 1-3). I can't replicate the issues you were facing. Opting into the width support for the paragraph block specifically, since that was mentioned in the error, worked fine as well (not suggesting we want support on that though).

My guess is if you were switching between branches with the build watch task running something went awry. Rebuilding this branch should sort it out.

We need a custom width panel for the image.

I'm not sure I follow what you are looking for here. Do you mean we want the simple UnitControl display of the width control for the image block? Or, that we need a completely custom dimensions panel for the image block? One that allows for the size control etc.

We need a "shortcut" width panel for Button.

By "shortcut" do you mean the version of the width control with the preset percentage widths? The panel for me is the dimensions panel. This PR is about the width block support and the control to support that.

It'd be nice to be able to switch from the latter to the former.

I take it that you are not referring to the toggle button to switch from the preset button group display of the width control to the basic unit control display.

At present, this width block support allows you to choose how the width control is presented. There are two options:

Basic UnitControl New Segmented Control

Block.json opts in with width: true

Screen Shot 2021-06-23 at 11 47 59 am

Block.json opts in with width: "segmented"

WidthControl3

Is there any chance you could use the segmented control from #31937?

Once that PR is finished and lands, we can definitely update this width control. It can be done separately to this PR. I imagine we'll want to also update other uses of button groups that can be replaced by that segmented control.

Agreed, let's try without the slider.
My biggest gotcha with this one is that when you click the edit icon to "unlock", you have to "tab backwards" to set focus in the width panel.

I'll remove the slider from the new width control. It should also be possible to set focus to the unit control after "unlocking" the basic view via the edit icon.

@aaronrobertshaw
Copy link
Contributor Author

The RangeControl has been removed from the "custom" (explicit width) view in d62467f

When switching to the custom view now, focus will be moved to the UnitControl. 5ab0a70

@jasmussen
Copy link
Contributor

I'm not sure I follow what you are looking for here. Do you mean we want the simple UnitControl display of the width control for the image block? Or, that we need a completely custom dimensions panel for the image block? One that allows for the size control etc.

I was unclear here. I was simply confirming your thoughts: we will need the shortcuts from the segmented control with some blocks, and we'll need just a basic width input field for others.

Your two options look good to me to try out 👍 👍

@paaljoachim
Copy link
Contributor

What are the next steps in this PR?
Thanks!

@aaronrobertshaw
Copy link
Contributor Author

What are the next steps in this PR?

Thanks for checking in @paaljoachim 👍

The height and width block supports weren't in the must-haves for 5.9 so were put on the back burner until recently.

Unfortunately, with the 5.9 release, we didn't have a means of overriding the theme.json classes to allow the addition of new block support features. This is currently being addressed with the required updates being backported to 5.9.1. As you would expect this has been a blocker to progressing this PR.

That said, I've been working on bringing the new block support PRs up-to-date and should be in a position to push those changes sometime this week.

In summary, the next steps are:

  • Finish debugging remaining issues/requirements for extending theme.json classes
  • Update the height support PR
  • Update this width support PR ( it currently is based on the height PR )
  • Extract the width control into its own component within the components package

@paaljoachim
Copy link
Contributor

Thanks for the update @aaronrobertshaw
It is much appreciated.

@aaronrobertshaw
Copy link
Contributor Author

That said, I've been working on bringing the new block support PRs up-to-date and should be in a position to push those changes sometime this week.

There are ongoing issues with being able to extend the theme.json settings which are preventing updating this PR. It may not be completed this week. I'll also be AFK until mid-March so there might be further delays on progressing width support.

@paaljoachim
Copy link
Contributor

It sounds like solving a few of the issues with the theme.json before landing this PR would be helpful.
Have a nice break Aaron!

@aaronrobertshaw
Copy link
Contributor Author

I've cherry-picked some commits from #38883 to allow the proper extension of theme.json and global styles.

At this time, this PR is working however there has been a recent change of plans around how we might manage the general layout of blocks. This might actually include new layout blocks specifically. It is yet to be seen how appropriate control over height and width will be within this context.

As a result, I will close this PR and the other related dimensions support PRs.(#32499, #32878)

@paaljoachim
Copy link
Contributor

Regarding...

At this time, this PR is working however there has been a recent change of plans around how we might manage the general layout of blocks. This might actually include new layout blocks specifically. It is yet to be seen how appropriate control over height and width will be within this context.

Is it possible to link to issues/PR's/more information about these things?
Thanks!

@aaronrobertshaw
Copy link
Contributor Author

Thanks for the question @paaljoachim. At this stage, I don't have any specific issues, PRs, or additional information about the layout blocks. Unfortunately, it is a bit too early for that and we'll need to do some exploration and experimentation first.

About the best I can do is offer this link highlighting the various layouts we'll be looking to offer whether by block supports/theme.json or dedicated layout blocks.

@paaljoachim
Copy link
Contributor

Interesting! Thank you @aaronrobertshaw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants