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

Suggest Block patterns in block placeholder states #29602

Merged
merged 15 commits into from
Apr 22, 2021

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Mar 6, 2021

Description

Resolves: #28735
Related: #27575

Based on the design: #28735 (comment)

When inserting something like a Query block, it may be useful to present the user with patterns that consume relevant block patterns and inspire them to create something more elaborate.

BlockPatternPicker component

For the suggestion of block patterns in placeholder states I've created a new component BlockPatternPicker which can handle this problem with minimal amount of new code, in any block that wants to use this. The concept is simple and you can see an example here.

  1. First you have to have a check when to show the Placeholder, which was the case before too.
  2. You can use the experimental patterns API to match block patterns with blockTypes property or you can provide a custom patterns filtering function (filterPatternsFn). This might be useful for template parts (?). This empowers the developer to show specific only patterns and handles the case of showing existing patterns that are desired. I have used this only for Query block for now to test with.
  3. Provide a startBlankComponent which is rendered if no block patterns are matched or we click Start blank.

In this POC I had implemented this in Buttons and Columns to test how it behaves with a block that previously had shown block variations picker(Columns) and one that hadn't (Buttons), but now have removed them since it's going to the last steps of landing. You can always check previous commits with the above blocks using the new component.

Notes

  1. This PR utilizes the experimental blockTypes property in Block patterns API introduced here: Block Patterns: Remove scope from Query patterns and introduce blockTypes #30471, in which we can 'connect' block patterns with blocks.
  2. I have removed the previous setting from placeholder for setting inherit attribute as it should probably be handled better with something like this issue: Context detection for Query block #30369

Showcase

query placeholder

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.

@ntsekouras ntsekouras added [Type] Feature New feature to highlight in changelogs. [Type] Experimental Experimental feature or API. [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Mar 6, 2021
@ntsekouras ntsekouras self-assigned this Mar 6, 2021
@github-actions
Copy link

github-actions bot commented Mar 6, 2021

Size Change: -647 B (0%)

Total Size: 1.47 MB

Filename Size Change
build/block-editor/index.js 131 kB +1.21 kB (+1%)
build/block-editor/style-rtl.css 13 kB +449 B (+4%)
build/block-editor/style.css 13 kB +445 B (+4%)
build/block-library/blocks/query/editor-rtl.css 131 B -679 B (-84%) 🏆
build/block-library/blocks/query/editor.css 132 B -677 B (-84%) 🏆
build/block-library/editor-rtl.css 9.47 kB -359 B (-4%)
build/block-library/editor.css 9.46 kB -361 B (-4%)
build/block-library/index.js 153 kB -931 B (-1%)
build/blocks/index.js 48.7 kB +112 B (0%)
build/components/index.js 285 kB +8 B (0%)
build/compose/index.js 11.6 kB -1 B (0%)
build/core-data/index.js 17 kB -152 B (-1%)
build/customize-widgets/index.js 8.25 kB -2 B (0%)
build/data-controls/index.js 836 B -1 B (0%)
build/data/index.js 9.17 kB +299 B (+3%)
build/date/index.js 31.9 kB -3 B (0%)
build/dom-ready/index.js 576 B -1 B (0%)
build/dom/index.js 5.12 kB +1 B (0%)
build/edit-navigation/index.js 17.1 kB -1 B (0%)
build/edit-post/index.js 339 kB -5 B (0%)
build/editor/index.js 42.6 kB +2 B (0%)
build/format-library/index.js 6.77 kB +1 B (0%)
build/keyboard-shortcuts/index.js 2.53 kB +1 B (0%)
build/keycodes/index.js 1.95 kB +1 B (0%)
build/media-utils/index.js 5.39 kB -1 B (0%)
build/notices/index.js 1.85 kB +1 B (0%)
build/primitives/index.js 1.42 kB +1 B (0%)
build/react-i18n/index.js 1.45 kB -1 B (0%)
build/redux-routine/index.js 2.84 kB +2 B (0%)
build/server-side-render/index.js 2.6 kB -1 B (0%)
build/shortcode/index.js 1.7 kB +1 B (0%)
build/warning/index.js 1.14 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.78 kB 0 B
build/api-fetch/index.js 3.41 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/blob/index.js 664 B 0 B
build/block-directory/index.js 8.62 kB 0 B
build/block-directory/style-rtl.css 1 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 112 B 0 B
build/block-library/blocks/audio/style.css 112 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 503 B 0 B
build/block-library/blocks/button/style.css 503 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 368 B 0 B
build/block-library/blocks/buttons/style.css 368 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 436 B 0 B
build/block-library/blocks/columns/style.css 435 B 0 B
build/block-library/blocks/cover/editor-rtl.css 605 B 0 B
build/block-library/blocks/cover/editor.css 605 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.23 kB 0 B
build/block-library/blocks/cover/style.css 1.23 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 401 B 0 B
build/block-library/blocks/embed/style.css 400 B 0 B
build/block-library/blocks/file/editor-rtl.css 301 B 0 B
build/block-library/blocks/file/editor.css 300 B 0 B
build/block-library/blocks/file/frontend.js 765 B 0 B
build/block-library/blocks/file/style-rtl.css 255 B 0 B
build/block-library/blocks/file/style.css 255 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB 0 B
build/block-library/blocks/freeform/editor.css 2.44 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 704 B 0 B
build/block-library/blocks/gallery/editor.css 705 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.09 kB 0 B
build/block-library/blocks/gallery/style.css 1.09 kB 0 B
build/block-library/blocks/group/editor-rtl.css 160 B 0 B
build/block-library/blocks/group/editor.css 160 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 717 B 0 B
build/block-library/blocks/image/editor.css 716 B 0 B
build/block-library/blocks/image/style-rtl.css 476 B 0 B
build/block-library/blocks/image/style.css 478 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 281 B 0 B
build/block-library/blocks/latest-comments/style.css 282 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 523 B 0 B
build/block-library/blocks/latest-posts/style.css 522 B 0 B
build/block-library/blocks/legacy-widget/editor-rtl.css 398 B 0 B
build/block-library/blocks/legacy-widget/editor.css 399 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 191 B 0 B
build/block-library/blocks/media-text/editor.css 191 B 0 B
build/block-library/blocks/media-text/style-rtl.css 535 B 0 B
build/block-library/blocks/media-text/style.css 532 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 597 B 0 B
build/block-library/blocks/navigation-link/editor.css 597 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 1.07 kB 0 B
build/block-library/blocks/navigation-link/style.css 1.07 kB 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.24 kB 0 B
build/block-library/blocks/navigation/editor.css 1.24 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 272 B 0 B
build/block-library/blocks/navigation/style.css 271 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 239 B 0 B
build/block-library/blocks/page-list/editor.css 240 B 0 B
build/block-library/blocks/page-list/style-rtl.css 167 B 0 B
build/block-library/blocks/page-list/style.css 167 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B 0 B
build/block-library/blocks/paragraph/editor.css 157 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 247 B 0 B
build/block-library/blocks/paragraph/style.css 248 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 250 B 0 B
build/block-library/blocks/post-comments-form/style.css 250 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B 0 B
build/block-library/blocks/post-excerpt/style.css 69 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 100 B 0 B
build/block-library/blocks/post-featured-image/style.css 100 B 0 B
build/block-library/blocks/post-title/style-rtl.css 60 B 0 B
build/block-library/blocks/post-title/style.css 60 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 103 B 0 B
build/block-library/blocks/preformatted/style.css 103 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 318 B 0 B
build/block-library/blocks/pullquote/style.css 318 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 83 B 0 B
build/block-library/blocks/query-loop/editor.css 82 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query-title/editor-rtl.css 86 B 0 B
build/block-library/blocks/query-title/editor.css 86 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 189 B 0 B
build/block-library/blocks/search/editor.css 189 B 0 B
build/block-library/blocks/search/style-rtl.css 359 B 0 B
build/block-library/blocks/search/style.css 362 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 251 B 0 B
build/block-library/blocks/separator/style.css 251 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 512 B 0 B
build/block-library/blocks/shortcode/editor.css 512 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 440 B 0 B
build/block-library/blocks/site-logo/editor.css 441 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 154 B 0 B
build/block-library/blocks/site-logo/style.css 154 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 796 B 0 B
build/block-library/blocks/social-links/editor.css 795 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB 0 B
build/block-library/blocks/social-links/style.css 1.33 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 308 B 0 B
build/block-library/blocks/spacer/editor.css 308 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 402 B 0 B
build/block-library/blocks/table/style.css 402 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 552 B 0 B
build/block-library/blocks/template-part/editor.css 551 B 0 B
build/block-library/blocks/term-description/editor-rtl.css 90 B 0 B
build/block-library/blocks/term-description/editor.css 90 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 568 B 0 B
build/block-library/blocks/video/editor.css 569 B 0 B
build/block-library/blocks/video/style-rtl.css 173 B 0 B
build/block-library/blocks/video/style.css 173 B 0 B
build/block-library/common-rtl.css 1.31 kB 0 B
build/block-library/common.css 1.31 kB 0 B
build/block-library/reset-rtl.css 502 B 0 B
build/block-library/reset.css 503 B 0 B
build/block-library/style-rtl.css 9.44 kB 0 B
build/block-library/style.css 9.44 kB 0 B
build/block-library/theme-rtl.css 692 B 0 B
build/block-library/theme.css 693 B 0 B
build/block-serialization-default-parser/index.js 1.87 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/components/style-rtl.css 16.2 kB 0 B
build/components/style.css 16.2 kB 0 B
build/customize-widgets/style-rtl.css 630 B 0 B
build/customize-widgets/style.css 631 B 0 B
build/deprecated/index.js 787 B 0 B
build/edit-navigation/style-rtl.css 2.86 kB 0 B
build/edit-navigation/style.css 2.86 kB 0 B
build/edit-post/classic-rtl.css 454 B 0 B
build/edit-post/classic.css 454 B 0 B
build/edit-post/style-rtl.css 6.96 kB 0 B
build/edit-post/style.css 6.95 kB 0 B
build/edit-site/index.js 28.9 kB 0 B
build/edit-site/style-rtl.css 4.9 kB 0 B
build/edit-site/style.css 4.89 kB 0 B
build/edit-widgets/index.js 16.7 kB 0 B
build/edit-widgets/style-rtl.css 2.97 kB 0 B
build/edit-widgets/style.css 2.98 kB 0 B
build/editor/style-rtl.css 3.9 kB 0 B
build/editor/style.css 3.9 kB 0 B
build/element/index.js 4.62 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.js 2.28 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 4.04 kB 0 B
build/is-shallow-equal/index.js 699 B 0 B
build/list-reusable-blocks/index.js 3.19 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/plugins/index.js 2.95 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/reusable-blocks/index.js 3.8 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/rich-text/index.js 13.5 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 3.01 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@ntsekouras ntsekouras changed the title POC: Suggest Block patterns in block placeholder states Suggest Block patterns in block placeholder states Mar 8, 2021
@jasmussen
Copy link
Contributor

Taking this one for a spin, a good reference, this is what an unconfigured columns block looks like, before:
before

Here's after:

after

One thing I like about this a lot is that this let's the placeholder state survive the squint test. That is — the placeholder is not just a white box, but it actually looks a little bit like the end result. I dig it.

There are some CSS tweaks to do here and there to get close to @jameskoster's design, I'm happy to help here get this perfect, if you like. I'll wait for others to chime in, but let me know when the time's right!

I recall a @mtias comment about when and where to best leverage this pattern, would be good to get a quick insight.

@jameskoster
Copy link
Contributor

Super excited to see this! In addition to the style tweaks Joen mentioned there's one thing on the technical side that I think once adjusted would improve the overall experience. In placeholder state I am currently able to see outlines when I hover blocks and inline inserter buttons which feels a bit odd. Ideally, in this preview state the blocks/canvas should be entirely non-interactive.

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Mar 9, 2021

I really like where this is going!

filtering function (filterPatternsFn). This might be useful for template parts (?)

Yes! It definitely seems like this would work great for that case as well.

In the template parts case I also see the startBlankComponent being less of an actual component we view and interact with, and more of a component that immediately triggers state back on the template part block to go back to rendering its blank inner blocks array again. Either way, it seems like a good set up that should work across a large variety of cases!

I am excited for TPs and other blocks to leverage this awesome new component. 😁

Let me know if there is anything I can do to help!

@jameskoster
Copy link
Contributor

Added the needs design label as a reminder to make the style adjustments mentioned above. I hope to get to this before the weekend.

@ntsekouras
Copy link
Contributor Author

Thanks all for reviewing/testing so far 👍 !

Added the needs design label as a reminder to make the style adjustments mentioned above. I hope to get to this before the weekend.

I'm actually waiting for a bit more feedback on this (besides the styling that will need polishing), and explorations on transforms will come in handy for the verification of the new API.

@Addison-Stavlo
Copy link
Contributor

and explorations on transforms will come in handy for the verification of the new API.

Do you think the component we have in this PR could be leveraged for the pattern transforms case as well? It seems like it would have a lot of similar functionalities and interface.

@mtias
Copy link
Member

mtias commented Mar 10, 2021

Great to see this!

I'd expect the grid view to be the exact same view as what we have in the quick inserter:

image

I recall a @mtias comment about when and where to best leverage this pattern, would be good to get a quick insight.

I think we'd want to move this flow into a modal to have it more focused and to also handle the problem of not enough space for so much interactivity. It might also help with the double-toolbar feel currently between the block toolbar and placeholder header.

As the pattern directory matures, we'd need to possibly connect this more broadly for a better browsing experience. But that's a later stage.

Do you think the component we have in this PR could be leveraged for the pattern transforms case as well?

There are some transforms that I'd expect to work more like:

image

And other cases, like a header template part, where the carousel would provide a much better experience. Particularly in the "isolated template part" flow, which is virtually the same as the modal suggested above.



// Buttons scoped pattern to test with Placeholder.
register_block_pattern(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjellr can we start thinking for which blocks we might want to have bundled patterns for? It doesn't have to be many, but it'd be good to be able to not rely on dummy patterns for testing and refining the UI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also to start thinking about: Looking forward to implementing this with template parts, Im guessing we should probably register ~2 header and 2 footer patterns in Gutenberg itself when the time comes? So that the patterns selection/transform can be used even if the theme or other plugins aren't registering any. Perhaps they should be new/unique? Or maybe we take from existing designs like tt1-blocks template parts? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjellr can we start thinking for which blocks we might want to have bundled patterns for?

Sounds good. Once the new patterns from #28921 are in, we can evaluate which other blocks could use some patterns too. 👍

@jameskoster
Copy link
Contributor

jameskoster commented Mar 10, 2021

I shared designs for transforms that consume this component in #28736 (comment).

As for some blocks surfacing patterns in grid view initially, and others in the carousel view, that seems to be a simple case of allowing blocks to specify a default orientation for this component.

The modal idea is interesting but there is one thing I'm struggling with: you lose the sense how the pattern will slot in alongside its siblings. This can be very important since some pattern layouts will no doubt adapt based on the dimensions of its container. If the modal is large and the target space small, the end result might not match the preview. Perhaps its possible for the modal dimensions to be influenced by the container? Or even be resizable (to draw more comparisons with isolation view (#29148))?

@ntsekouras
Copy link
Contributor Author

What do we need to move this forward?

From my side I can see these things:

  1. Decide what block or blocks will use this component initially and handle some new patterns probably (Suggest Block patterns in block placeholder states #29602 (comment))?
  2. Polish the styles, when design/view is decided
  3. After the above I'll handle the last code refactorings/tests etc..

I think we'd want to move this flow into a modal to have it more focused and to also handle the problem of not enough space for so much interactivity. It might also help with the double-toolbar feel currently between the block toolbar and placeholder header.

Is this something that needs design decision?

@Addison-Stavlo
Copy link
Contributor

Also wondering if we can get some basic test (e2e?) coverage for this component once its ready.

@jasmussen
Copy link
Contributor

Good review items. I'll look at the scrollbars/boundary issue, and look at adding a border in the grid view.

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Apr 21, 2021

I'll look at the scrollbars/boundary issue

It seems that part may be a theme issue. I am observing the issue with tt1-blocks, but it seems perfectly fine when i test with mayland-blocks

Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great! My feedback is minor; beyond that, LGTM.

@jasmussen
Copy link
Contributor

Added gray borders for patterns inside grid mode, and fixed the sizing issue.

@ntsekouras
Copy link
Contributor Author

Where it says "Loading..." could we show the spinner instead?

Created an issue here: #31071

@ntsekouras ntsekouras requested review from nerrad and ntwb as code owners April 22, 2021 11:26
@ntsekouras ntsekouras merged commit 6244cf5 into trunk Apr 22, 2021
@ntsekouras ntsekouras deleted the try/patterns-placeholder branch April 22, 2021 12:15
@github-actions github-actions bot added this to the Gutenberg 10.6 milestone Apr 22, 2021
@mtias
Copy link
Member

mtias commented Apr 22, 2021

Thanks for all the work here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced Needs Design Needs design efforts. [Type] Experimental Experimental feature or API. [Type] Feature New feature to highlight in changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest Patterns in block placeholder states
9 participants