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

Group block: use a variation picker in the placeholder #43496

Merged
merged 24 commits into from
Nov 15, 2022

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Aug 23, 2022

What?

Implement a variation-selector placeholder for the Group block for web browsers (not mobile).

Resolves: #43433

Why?

For ease of access to current and future layouts.

How?

Using <__experimentalBlockVariationPicker /> also used by the Columns block.

Testing Instructions

In trunk create a few group blocks:

Here are some:
<!-- wp:group {"layout":{"type":"constrained","isDefault":true}} -->
<div class="wp-block-group"></div>
<!-- /wp:group -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:group {"layout":{"type":"constrained","isDefault":true}} -->
<div class="wp-block-group"></div>
<!-- /wp:group --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:group {"layout":{"type":"constrained","isDefault":true}} -->
<div class="wp-block-group"></div>
<!-- /wp:group --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

Save the post.

Checkout this branch git checkout -t origin/try/group-variation-placeholder.

Refresh the editor.

Check that the Group blocks appear as they should (no placeholder).

Now insert a new Group block.

You should see the variation placeholder picker.

Check behaviour in the site editor as well.

Expectations:

  • When a flex layout (row or stack) is selected, the placeholder should not be displayed. Even after refreshing the page.
  • When the default group variation has been selected, and styles are applied, the placeholder should not be displayed. Even after refreshing the page.
  • When there are innerblocks, the placeholder should not be displayed. Even after refreshing the page.
  • The layout should default to is-layout-constrained when transforming blocks to Group blocks, including multiselect transforms.
  • The group block should work as expected in block and classic themes.
  • After selecting a group variation the newly-inserted block should be selected.

Screenshots or screencast

Screen Shot 2022-11-04 at 12 33 23 pm

@ramonjd ramonjd requested a review from ajitbohra as a code owner August 23, 2022 04:01
@github-actions
Copy link

github-actions bot commented Aug 23, 2022

Size Change: +1.44 kB (0%)

Total Size: 1.3 MB

Filename Size Change
build/block-library/blocks/group/editor-rtl.css 654 B +260 B (+66%) 🆘
build/block-library/blocks/group/editor.css 654 B +260 B (+66%) 🆘
build/block-library/editor-rtl.css 11.5 kB +143 B (+1%)
build/block-library/editor.css 11.4 kB +139 B (+1%)
build/block-library/index.min.js 194 kB +640 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 982 B
build/annotations/index.min.js 2.76 kB
build/api-fetch/index.min.js 2.26 kB
build/autop/index.min.js 2.14 kB
build/blob/index.min.js 475 B
build/block-directory/index.min.js 7.09 kB
build/block-directory/style-rtl.css 990 B
build/block-directory/style.css 991 B
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-editor/index.min.js 174 kB
build/block-editor/style-rtl.css 15.9 kB
build/block-editor/style.css 15.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 90 B
build/block-library/blocks/archives/style.css 90 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 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 126 B
build/block-library/blocks/audio/theme.css 126 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 84 B
build/block-library/blocks/avatar/style.css 84 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 482 B
build/block-library/blocks/button/editor.css 482 B
build/block-library/blocks/button/style-rtl.css 532 B
build/block-library/blocks/button/style.css 532 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 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 100 B
build/block-library/blocks/categories/style.css 100 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 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-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 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-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 612 B
build/block-library/blocks/cover/editor.css 613 B
build/block-library/blocks/cover/style-rtl.css 1.57 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 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 126 B
build/block-library/blocks/embed/theme.css 126 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 253 B
build/block-library/blocks/file/style.css 254 B
build/block-library/blocks/file/view.min.js 346 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 948 B
build/block-library/blocks/gallery/editor.css 950 B
build/block-library/blocks/gallery/style-rtl.css 1.53 kB
build/block-library/blocks/gallery/style.css 1.53 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 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 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/html/editor-rtl.css 327 B
build/block-library/blocks/html/editor.css 329 B
build/block-library/blocks/image/editor-rtl.css 880 B
build/block-library/blocks/image/editor.css 880 B
build/block-library/blocks/image/style-rtl.css 627 B
build/block-library/blocks/image/style.css 630 B
build/block-library/blocks/image/theme-rtl.css 126 B
build/block-library/blocks/image/theme.css 126 B
build/block-library/blocks/latest-comments/style-rtl.css 298 B
build/block-library/blocks/latest-comments/style.css 298 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 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 507 B
build/block-library/blocks/media-text/style.css 505 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 712 B
build/block-library/blocks/navigation-link/editor.css 711 B
build/block-library/blocks/navigation-link/style-rtl.css 115 B
build/block-library/blocks/navigation-link/style.css 115 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 296 B
build/block-library/blocks/navigation-submenu/editor.css 295 B
build/block-library/blocks/navigation/editor-rtl.css 2.15 kB
build/block-library/blocks/navigation/editor.css 2.16 kB
build/block-library/blocks/navigation/style-rtl.css 2.21 kB
build/block-library/blocks/navigation/style.css 2.2 kB
build/block-library/blocks/navigation/view-modal.min.js 2.78 kB
build/block-library/blocks/navigation/view.min.js 443 B
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 363 B
build/block-library/blocks/page-list/editor.css 363 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 174 B
build/block-library/blocks/paragraph/editor.css 174 B
build/block-library/blocks/paragraph/style-rtl.css 279 B
build/block-library/blocks/paragraph/style.css 281 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/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 501 B
build/block-library/blocks/post-comments-form/style.css 501 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 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 586 B
build/block-library/blocks/post-featured-image/editor.css 584 B
build/block-library/blocks/post-featured-image/style-rtl.css 315 B
build/block-library/blocks/post-featured-image/style.css 315 B
build/block-library/blocks/post-navigation-link/style-rtl.css 153 B
build/block-library/blocks/post-navigation-link/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 282 B
build/block-library/blocks/post-template/style.css 282 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 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 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 326 B
build/block-library/blocks/pullquote/style.css 325 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 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 440 B
build/block-library/blocks/query/editor.css 440 B
build/block-library/blocks/quote/style-rtl.css 213 B
build/block-library/blocks/quote/style.css 213 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 409 B
build/block-library/blocks/search/style.css 406 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 464 B
build/block-library/blocks/shortcode/editor.css 464 B
build/block-library/blocks/site-logo/editor-rtl.css 490 B
build/block-library/blocks/site-logo/editor.css 490 B
build/block-library/blocks/site-logo/style-rtl.css 203 B
build/block-library/blocks/site-logo/style.css 203 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 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 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.4 kB
build/block-library/blocks/social-links/style.css 1.39 kB
build/block-library/blocks/spacer/editor-rtl.css 322 B
build/block-library/blocks/spacer/editor.css 322 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 505 B
build/block-library/blocks/table/editor.css 505 B
build/block-library/blocks/table/style-rtl.css 631 B
build/block-library/blocks/table/style.css 631 B
build/block-library/blocks/table/theme-rtl.css 172 B
build/block-library/blocks/table/theme.css 172 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 235 B
build/block-library/blocks/template-part/editor.css 235 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 691 B
build/block-library/blocks/video/editor.css 694 B
build/block-library/blocks/video/style-rtl.css 174 B
build/block-library/blocks/video/style.css 174 B
build/block-library/blocks/video/theme-rtl.css 126 B
build/block-library/blocks/video/theme.css 126 B
build/block-library/classic-rtl.css 162 B
build/block-library/classic.css 162 B
build/block-library/common-rtl.css 1.02 kB
build/block-library/common.css 1.02 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 478 B
build/block-library/reset.css 478 B
build/block-library/style-rtl.css 12.4 kB
build/block-library/style.css 12.4 kB
build/block-library/theme-rtl.css 704 B
build/block-library/theme.css 708 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/blocks/index.min.js 49.9 kB
build/components/index.min.js 203 kB
build/components/style-rtl.css 11.5 kB
build/components/style.css 11.5 kB
build/compose/index.min.js 12.2 kB
build/core-data/index.min.js 15.5 kB
build/customize-widgets/index.min.js 11.3 kB
build/customize-widgets/style-rtl.css 1.38 kB
build/customize-widgets/style.css 1.38 kB
build/data-controls/index.min.js 653 B
build/data/index.min.js 8.08 kB
build/date/index.min.js 32.1 kB
build/deprecated/index.min.js 507 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.7 kB
build/edit-navigation/index.min.js 16.2 kB
build/edit-navigation/style-rtl.css 4.05 kB
build/edit-navigation/style.css 4.06 kB
build/edit-post/classic-rtl.css 546 B
build/edit-post/classic.css 547 B
build/edit-post/index.min.js 34.6 kB
build/edit-post/style-rtl.css 7.38 kB
build/edit-post/style.css 7.37 kB
build/edit-site/index.min.js 61.1 kB
build/edit-site/style-rtl.css 8.38 kB
build/edit-site/style.css 8.36 kB
build/edit-widgets/index.min.js 16.8 kB
build/edit-widgets/style-rtl.css 4.4 kB
build/edit-widgets/style.css 4.4 kB
build/editor/index.min.js 43.7 kB
build/editor/style-rtl.css 3.6 kB
build/editor/style.css 3.59 kB
build/element/index.min.js 4.68 kB
build/escape-html/index.min.js 537 B
build/experiments/index.min.js 868 B
build/format-library/index.min.js 6.95 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.64 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.77 kB
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.78 kB
build/keycodes/index.min.js 1.83 kB
build/list-reusable-blocks/index.min.js 2.13 kB
build/list-reusable-blocks/style-rtl.css 835 B
build/list-reusable-blocks/style.css 835 B
build/media-utils/index.min.js 2.93 kB
build/notices/index.min.js 963 B
build/nux/index.min.js 2.06 kB
build/nux/style-rtl.css 732 B
build/nux/style.css 728 B
build/plugins/index.min.js 1.94 kB
build/preferences-persistence/index.min.js 2.22 kB
build/preferences/index.min.js 1.33 kB
build/primitives/index.min.js 944 B
build/priority-queue/index.min.js 1.58 kB
build/react-i18n/index.min.js 696 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.74 kB
build/reusable-blocks/index.min.js 2.21 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.7 kB
build/server-side-render/index.min.js 1.77 kB
build/shortcode/index.min.js 1.53 kB
build/style-engine/index.min.js 1.48 kB
build/token-list/index.min.js 644 B
build/url/index.min.js 3.61 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 38.5 kB
build/vendors/react.min.js 4.34 kB
build/viewport/index.min.js 1.08 kB
build/warning/index.min.js 268 B
build/widgets/index.min.js 7.21 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.19 kB
build/wordcount/index.min.js 1.06 kB

compressed-size-action

@ramonjd ramonjd self-assigned this Aug 23, 2022
@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Block Variations Block variations, including introducing new variations and variations as a feature [Status] In Progress Tracking issues with work in progress labels Aug 23, 2022
@ramonjd ramonjd requested a review from ellatrix as a code owner August 24, 2022 02:13
@ramonjd ramonjd requested review from ntwb and nerrad as code owners August 24, 2022 05:36
@ramonjd
Copy link
Member Author

ramonjd commented Aug 24, 2022

To follow up:

Looks like we can add attributes here if required:

@ramonjd
Copy link
Member Author

ramonjd commented Aug 25, 2022

Check whether the templates need a layout.

With this PR, if a group block is programmatically created without a layout (e.g., with registerBlockType, register_post_type docs), and the template doesn't set a default layout type of 'constrained', children of a wide-aligned group block will not "constrain" themselves within the content width.

Screen Shot 2022-08-25 at 2 19 10 pm

Example block HTML
<!-- wp:group {"align":"full","backgroundColor":"vivid-red"} -->
<div class="wp-block-group alignfull has-vivid-red-background-color has-background"><!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"right"} -->
<p class="has-text-align-right">Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:group {"layout":{"type":"constrained"},"backgroundColor":"luminous-vivid-orange"} -->
<div class="wp-block-group has-luminous-vivid-orange-background-color has-background"><!-- wp:paragraph -->
<p>Paragraph inside a Group block inside a Group block</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

<!-- wp:group {"layout":{"type":"constrained"},"align":"full","backgroundColor":"vivid-purple"} -->
<div class="wp-block-group alignfull has-vivid-purple-background-color has-background"><!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"left"} -->
<p class="has-text-align-left">Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"right"} -->
<p class="has-text-align-right">Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph inside a Group block</p>
<!-- /wp:paragraph -->

<!-- wp:group {"layout":{"type":"constrained"},"backgroundColor":"luminous-vivid-orange"} -->
<div class="wp-block-group has-luminous-vivid-orange-background-color has-background"><!-- wp:paragraph -->
<p>Paragraph inside a Group block inside a Group block</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

This is a bit of a blocker in my opinion, at least until we work out an acceptable way around it.

The placeholder is premised on the ability to select a layout with the implication that no layout is yet selected. A recent PR introduced changes the Group block so newly-added blocks are automatically set to “constrained” layout. Newly-added comprises blocks added in the editor and those programmatically, via templates.

If we are to honour the default layout attributes in the group block, we need to somehow know that a block has been recently inserted in the editor, since all newly-created blocks will have the default layout. wasBlockJustInserted( clientId ) does not work.

An alternative is to add a flag in the block json to indicate that the default value is being used:

		"layout": {
			"type": "object",
			"default": {
				"type": "constrained",
				"isDefault": true
			}
		}

Then, in edit.js, we know to show to the placeholder in the editor if this attribute prop exists, and there are no inner blocks too. When a use selects a layout isDefault won't exist.

	const { tagName: TagName = 'div', templateLock, layout = {} } = attributes;
	const { type: layoutType = null, isDefault = false } = layout;

	// Whether to show the variations placeholder.
	// `isDefault: true` only exists in the default layout attributes in block.json
	// in order to identify blocks that have been inserted, programmatically or otherwise, with no changes.
	// When a user selects a layout `isDefault` won't appear in the block's attributes.
	const showPlaceholder = isDefault && ! hasInnerBlocks;

@ramonjd
Copy link
Member Author

ramonjd commented Aug 25, 2022

Another bug:

When inserting a Group block, the block is not focussed as with all other blocks.

Tried selectBlock after insertion.

This test fails:

await expect( await getActiveLabel() ).toBe( 'Block: Group' );

@ramonjd ramonjd force-pushed the try/group-variation-placeholder branch from 6b46208 to d5ef0f8 Compare September 6, 2022 01:08
@ramonjd ramonjd removed the [Status] In Progress Tracking issues with work in progress label Sep 6, 2022
@ramonjd
Copy link
Member Author

ramonjd commented Sep 6, 2022

I've addressed the default 'is-constrained' in #43496 (comment) and selected block issues in #43496 (comment) in c1b2044 and d5ef0f8 respectively.

@jasmussen
Copy link
Contributor

Nice, thanks for the ping! From #43433, which this would fix, here's a mockup for how this could look:

Here's the current state of the branch:

Screenshot 2022-09-06 at 08 39 52

I'm happy to help push style changes here if helpful, but for now I'll share changes as a list, then I trust you to let me know if my assistance would be helpful:

  • We don't need the "Skip", as it does the same as clicking Group.
  • Anything we can do to move away from the classic placeholder style (icon/title/description) for this one, and towards the leaner one would be good, as we need for placeholders to contain as little content as possible to scale to as many narrow contexts as possible.
  • Should use the new description.
  • Should use tertiary style of buttons, with new illustrations which I'll provide the SVGs for in a moment.

No need to add the following illustrations to the icon library, these can exist just for the Group. Stack:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 32" style="enable-background:new 0 0 44 32" xml:space="preserve"><path d="M42 0H2C.9 0 0 .9 0 2v12.5c0 .6.4 1 1 1h42c.6 0 1-.4 1-1V2c0-1.1-.9-2-2-2zm1 16.5H1c-.6 0-1 .4-1 1V30c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V17.5c0-.6-.4-1-1-1z" style="fill:#ccc"/></svg>

Row:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 32" style="enable-background:new 0 0 44 32" xml:space="preserve"><path d="M42 0H23.5c-.6 0-1 .4-1 1v30c0 .6.4 1 1 1H42c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM20.5 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h18.5c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1z" style="fill:#ccc"/></svg>

Group:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 32" style="enable-background:new 0 0 44 32" xml:space="preserve"><path d="M42 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2z" style="fill:#ccc"/></svg>

Let me know what you think!

@jasmussen
Copy link
Contributor

Anything we can do to move away from the classic placeholder style (icon/title/description) for this one, and towards the leaner one would be good, as we need for placeholders to contain as little content as possible to scale to as many narrow contexts as possible.

To elaborate a bit, I would expect every classic placeholder to eventually move towards either the dashed style (see unselected image placeholder) or the above style (white card but with minimal setup options). Columns and Table also come to mind. This is not something that needs to happen in short order for all of those, but is nevertheless a destination to move towards, and worth considering how that impacts the implementation, i.e. the above isn't a one-off for the group.

@ramonjd
Copy link
Member Author

ramonjd commented Sep 6, 2022

Thanks for the guidance, @jasmussen! 🙇

I was hoping that we could perhaps get the base functionality in and then work on the styles immediately after merging? It might be easier to iterate and separate the code review from the style (?) Also to keep the size of this one in check.

There are a couple of things that I think wouldn't create too much noise among the refactoring etc going on this PR however.

We don't need the "Skip", as it does the same as clicking Group.
Should use the new description.

Definitely doable. I will commit the following changes:

Screen Shot 2022-09-06 at 8 35 55 pm

Edit: the skip button features in a lot of E2E tests so I'll leave that for another commit so I don't break CI 🤭

Anything we can do to move away from the classic placeholder style (icon/title/description) for this one, and towards the leaner one would be good, as we need for placeholders to contain as little content as possible to scale to as many narrow contexts as possible.

I've reused the <__experimentalBlockVariationPicker />, which is also used by the Columns block. So we could probably refactor/redesign that one at the same time?

Screen Shot 2022-09-06 at 8 12 09 pm

Should use tertiary style of buttons, with new illustrations which I'll provide the SVGs for in a moment.

If we want to create a reusable component with the leaner style might require a bit of a refactor, and/or an extension of the variations objects, perhaps adding a placeholderIcon field for an alternative SVG.

React also complains about the style attribute in the svg and path elements so we might have to save them as images.

I did a quick test of just swapping the icons and removing the offending svg props:

Screen Shot 2022-09-06 at 8 30 23 pm

@jasmussen
Copy link
Contributor

In order to land this before the freeze, yes we probably can work towards a minimal v1 and then move fast on the visual changes after that fact.

We should distinguish between icons and illustrations. The group/row/stack icons should not change (and they also shouldn't be scaled up to double size). Columns is an example as it retains its default columns icon, but includes illustrations for the various variants in columns/variations.js. We can definitely do the same here, for starters with the SVGs provided, but depending on how far we get in the followups we could tweak the group variation illustration style to be outlined like the columns ones are. I'd prefer we improve the Columns variations instead, though, and I'd be happy to provide the new illustration style icons to those variations instead.

What do you think?

@ramonjd
Copy link
Member Author

ramonjd commented Sep 6, 2022

We should distinguish between icons and illustrations. The group/row/stack icons should not change (and they also shouldn't be scaled up to double size).

Definitely should be the goal 👍

Columns is an example as it retains its default columns icon, but includes illustrations for the various variants in columns/variations.js. We can definitely do the same here, for starters with the SVGs provided, but depending on how far we get in the followups we could tweak the group variation illustration style to be outlined like the columns ones are.

The difference between columns and group variations is that the group variations are shown in the inserter and transform scopes, and there's not yet a way to differentiate between scopes for the purpose of distinguishing between icons and illustrations (or anything else).

So my guess is one would have to extend the variations API, or create something bespoke for variation placeholders. Not sure yet.

It makes me think that it might take a bit longer than is available before freeze to get something stable through the hoop, on top of the other migration work. 🤔

If the functionality as it is appears like an improvement, it could be part of 6.1, then work could continue on both the UI and the plan to rework other placeholders later?

@jasmussen
Copy link
Contributor

With improvements to group/row/stacks on their own (clearer icons, multiple interfaces for transforming, clearer empty resting states), #43433 does need a bit of fidelity in order to be a better experience. I do think the right design helps it achieve that, but would also agree, if we don't think we can get there, maybe it won't be a 6.1 thing, but it would still benefit the plugin. So we have until sep 20 to figure that out. Is the main problem the need to refactor the placeholder component or the variation picker?

@ramonjd
Copy link
Member Author

ramonjd commented Sep 7, 2022

So we have until sep 20 to figure that out. Is the main problem the need to refactor the placeholder component or the variation picker?

Good question!

I think the answer is "potentially both" but maybe only the variation picker 😄

We'd need to work on the variation picker both in terms of styling and code - positioning the variations, and adding logic to use images/icons other than those used in the inserter for example.

This way we could take on the columns and group placeholders at the same time, if that's desirable.

The variation picker uses the placeholder component - I'm not 100% sure we'd need to do anything quite yet, unless we want to, for example, change the outline of all placeholder containers.

Ultimately, I don't think it'll be difficult task to tweak the design, yet believe it'd be better suited to separate PRs as they would be easier to review and test.

I'm very happy to work on it, but the catch is I'm away next week and still have to devote some time to migrating all the PHP files it appears I've touched this year 🤣

@ramonjd
Copy link
Member Author

ramonjd commented Sep 7, 2022

I've been playing around to test some of my assumptions.

For this PR (or a direct follow up)1, I can get it looking something like this without too much refactoring ping pong and PR clutter:

2022-09-07.12.43.37.mp4

I'm still convinced that it'd be better to tackle the placeholder/variation placeholder holistically. For example, the main "Group" heading is controlled by <Placeholder /> so it'd need an exception. Also, the labels beneath the button would need an exception.

Footnotes

  1. I've pushed the change to this branch. We can roll back if we want to merge functionality now and design later.

@ramonjd ramonjd force-pushed the try/group-variation-placeholder branch 2 times, most recently from e9fce8f to dbb8a9c Compare September 7, 2022 05:25
@tellthemachines
Copy link
Contributor

I've pushed the change to this branch. We can roll back if we want to merge functionality now and design later.

Is there any downside to merging this design now? If we're changing the UI ideally we should do it in as few steps as possible, so as not to subject users to constant change.

I haven't looked at the code in detail but it's working pretty well in testing ✅

@jasmussen
Copy link
Contributor

Thanks so much for looking!

I'm also a big fan of small iterations, but we want to be sure that we can get very close to the mockup here, for 6.1, otherwise I would lean towards us doing this in, as you call it, "the holistic way".

To put it differently: this one is important in the slightly longer than 6.1 view, but it isn't as urgent as everything else is, so we don't have to rush it.

…hemeral property to identify blocks that have been inserted.
- default layout is "constrained" when programmatically inserting a group block
- using createBlock with no attributes passed
…pdate (and potentially break) the blockvariationpicker component, which is used elsewhere.
Add class to button.
Fix outline heights for button.
Updating design/spacing of placeholder
Hardcoding custom icons
…on to keep track of whether a variation has been selected since it adds a potentially useless attribute.

In this iteration, we'll keep track of whether to show the placeholder via useState in the editor, and, more permanently, whether the block has innerblocks.
Testing on the CI whether the changes to CPT are required :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Block Variations Block variations, including introducing new variations and variations as a feature Needs User Documentation Needs new user documentation [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group: Add setup state to allow picking a variant (default/row/stack)
8 participants