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

Add constrained/flow layout to Cover block. #45326

Merged
merged 6 commits into from
Mar 8, 2023
Merged

Conversation

tellthemachines
Copy link
Contributor

Why?

Closes #43140.

Adds support for constrained (as default) and flow layout to Cover block.

How?

Now that #44600 is merged, layout classnames are applied to the block inner wrapper by default. This means that layout support will work in Cover block in the same way as it does in e.g. Group (but without the flex variations for now).

Testing Instructions

  1. Add a Cover block to a post;
  2. Check that the Layout section now displays in the sidebar;
  3. Check that constrained layout applies by default to Cover children;
  4. Check that Cover children now have wide/full alignment controls where applicable.

TODO:

Existing Cover blocks should not change their layouts. I haven't done any testing for this yet, but anticipate some tweaks may be needed. I don't think a deprecation should be required because we're only adding functionality, not changing anything existing.

Screenshots or screencast

Screen Shot 2022-10-27 at 11 14 12 am

@tellthemachines tellthemachines self-assigned this Oct 27, 2022
@tellthemachines tellthemachines added [Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Layout Layout block support, its UI controls, and style output. labels Oct 27, 2022
@github-actions
Copy link

github-actions bot commented Oct 27, 2022

Size Change: +213 B (0%)

Total Size: 1.34 MB

Filename Size Change
build/block-editor/index.min.js 197 kB +11 B (0%)
build/block-library/index.min.js 201 kB +77 B (0%)
build/components/index.min.js 208 kB +15 B (0%)
build/edit-site/index.min.js 63.6 kB +36 B (0%)
build/edit-site/style-rtl.css 10.1 kB +36 B (0%)
build/edit-site/style.css 10.1 kB +38 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 993 B
build/annotations/index.min.js 2.78 kB
build/api-fetch/index.min.js 2.27 kB
build/autop/index.min.js 2.15 kB
build/blob/index.min.js 483 B
build/block-directory/index.min.js 7.2 kB
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.11 kB
build/block-editor/content.css 4.1 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-editor/style-rtl.css 14.4 kB
build/block-editor/style.css 14.4 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 138 B
build/block-library/blocks/audio/theme.css 138 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 91 B
build/block-library/blocks/avatar/style.css 91 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 628 B
build/block-library/blocks/button/style.css 627 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.56 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 138 B
build/block-library/blocks/embed/theme.css 138 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 265 B
build/block-library/blocks/file/style.css 265 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 984 B
build/block-library/blocks/gallery/editor.css 988 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 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 654 B
build/block-library/blocks/group/editor.css 654 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 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 830 B
build/block-library/blocks/image/editor.css 829 B
build/block-library/blocks/image/style-rtl.css 652 B
build/block-library/blocks/image/style.css 652 B
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 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 716 B
build/block-library/blocks/navigation-link/editor.css 715 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 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.13 kB
build/block-library/blocks/navigation/editor.css 2.14 kB
build/block-library/blocks/navigation/style-rtl.css 2.22 kB
build/block-library/blocks/navigation/style.css 2.2 kB
build/block-library/blocks/navigation/view-modal.min.js 2.81 kB
build/block-library/blocks/navigation/view.min.js 447 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 401 B
build/block-library/blocks/page-list/editor.css 401 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 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 134 B
build/block-library/blocks/post-excerpt/style.css 134 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 318 B
build/block-library/blocks/post-featured-image/style.css 318 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 463 B
build/block-library/blocks/query/editor.css 463 B
build/block-library/blocks/quote/style-rtl.css 222 B
build/block-library/blocks/quote/style.css 222 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 149 B
build/block-library/blocks/rss/editor.css 149 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 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 489 B
build/block-library/blocks/site-logo/editor.css 489 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 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 433 B
build/block-library/blocks/table/editor.css 433 B
build/block-library/blocks/table/style-rtl.css 651 B
build/block-library/blocks/table/style.css 650 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 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 404 B
build/block-library/blocks/template-part/editor.css 404 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 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 179 B
build/block-library/blocks/video/style.css 179 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 11.6 kB
build/block-library/editor.css 11.6 kB
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.7 kB
build/block-library/style.css 12.7 kB
build/block-library/theme-rtl.css 698 B
build/block-library/theme.css 703 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/blocks/index.min.js 51 kB
build/components/style-rtl.css 11.7 kB
build/components/style.css 11.7 kB
build/compose/index.min.js 12.4 kB
build/core-data/index.min.js 16.2 kB
build/customize-widgets/index.min.js 12.2 kB
build/customize-widgets/style-rtl.css 1.41 kB
build/customize-widgets/style.css 1.41 kB
build/data-controls/index.min.js 663 B
build/data/index.min.js 8.58 kB
build/date/index.min.js 40.4 kB
build/deprecated/index.min.js 518 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.72 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-post/index.min.js 34.8 kB
build/edit-post/style-rtl.css 7.53 kB
build/edit-post/style.css 7.52 kB
build/edit-widgets/index.min.js 17.3 kB
build/edit-widgets/style-rtl.css 4.55 kB
build/edit-widgets/style.css 4.55 kB
build/editor/index.min.js 45.7 kB
build/editor/style-rtl.css 3.54 kB
build/editor/style.css 3.53 kB
build/element/index.min.js 4.95 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 7.26 kB
build/format-library/style-rtl.css 557 B
build/format-library/style.css 556 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.79 kB
build/keycodes/index.min.js 1.94 kB
build/list-reusable-blocks/index.min.js 2.14 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.99 kB
build/notices/index.min.js 977 B
build/plugins/index.min.js 1.95 kB
build/preferences-persistence/index.min.js 2.23 kB
build/preferences/index.min.js 1.35 kB
build/primitives/index.min.js 960 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 937 B
build/react-i18n/index.min.js 702 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.75 kB
build/reusable-blocks/index.min.js 2.26 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/rich-text/index.min.js 11 kB
build/server-side-render/index.min.js 2.09 kB
build/shortcode/index.min.js 1.52 kB
build/style-engine/index.min.js 1.53 kB
build/token-list/index.min.js 650 B
build/url/index.min.js 3.74 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 1.09 kB
build/warning/index.min.js 280 B
build/widgets/index.min.js 7.3 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.06 kB

compressed-size-action

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Nice one, thanks for the quick follow-up!

Existing Cover blocks should not change their layouts. I haven't done any testing for this yet, but anticipate some tweaks may be needed.

Yes, it looks like we'll need some kind of intervention to work out how existing blocks should be handled. From testing with a Cover block on trunk set to the Center Center justification in the toolbar controls, there's a change in how the blocks are laid out. Here's a before and after:

Trunk The same post loaded with this branch
image image

Also, it looks like the justification controls are exposed in the layout controls in the sidebar, which are different and conflict slightly with the ones the Cover block provides in the toolbar. E.g. justify left and right only work if the Toolbar control is set to Center Center:

image

Should the justification controls be hidden for the moment, or alternately, should they play nicely with the Cover block's ad hoc controls I wonder 🤔

@@ -192,6 +198,7 @@ function CoverEdit( {
templateInsertUpdatesSelection: true,
allowedBlocks,
templateLock,
__experimentalLayout: usedLayout,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to inject this automatically in the block support instead? It seems this should be done automatically for blocks that have the "layout" block support enabled no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should, and this is one of the things we need to tackle before stabilising layout. Currently, the alignment controls of the child blocks depend on the layout settings being passed explicitly through innerBlocks. We have an open issue for it: #43731

I thought I'd go ahead with adding layout to Cover as it's one of the back-compat features requested by folks adding theme.json to their classic themes (so that Cover children can use the theme content width - see #33374 for more context). Once we have worked out a way to do this automatically, we can go back and remove the logic from existing blocks; we already pass layout to innerBlocks in most blocks that use it.

@tellthemachines
Copy link
Contributor Author

Thanks for reviewing and testing, folks!

From testing with a Cover block on trunk set to the Center Center justification in the toolbar controls, there's a change in how the blocks are laid out.

I think that's an inevitable consequence of making "constrained" the default, so I've made it default to "flow" for now. This won't be great for the classic theme folks wanting to experiment with theme.json though - the idea of having "constrained" as default was to make that transition process more seamless.

Should the justification controls be hidden for the moment, or alternately, should they play nicely with the Cover block's ad hoc controls I wonder 🤔

Unfortunately Cover block matrix and the layout justification controls have completely different implementations, with the matrix styles coming from the block library stylesheet, so there's no way of making them work together unless we want to try re-implementing matrix as a layout-type control 😅 so I've hidden the justification controls for now.

@tellthemachines
Copy link
Contributor Author

Thought I'd try what we're doing with the Group block and add constrained layout as a default block variation. This should mean that existing blocks will get flow layout applied but any new blocks added will be constrained. This seems like a good intermediate solution, and it's the same we adopted for Group. What does everyone think?

@github-actions
Copy link

github-actions bot commented Feb 1, 2023

Flaky tests detected in 543568c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4139187243
📝 Reported issues:

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Thanks for your work @tellthemachines!

I'd feel more comfortable if this could get more testing before landing today and therefore in 6.2. I haven't tested thoroughly but there are visible style changes in existing Cover blocks.

I have an example screenshot below that shows the margins are different for innerBlocks.

Screen.Recording.2023-02-01.at.11.32.32.AM.mov

packages/block-library/src/cover/block.json Show resolved Hide resolved
attributes: { layout: { type: 'constrained' } },
isDefault: true,
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need isActive and scope:block|transform here, since we don't have any other variations..

@tellthemachines
Copy link
Contributor Author

Thanks for taking the time to review and test this @ntsekouras ! I thought with the latest commit existing blocks weren't changing anymore, but something must have escaped me. If you have a moment, could you share the markup for those test blocks where you see changes?

@ntsekouras
Copy link
Contributor

Thanks for taking the time to review and test this @ntsekouras ! I thought with the latest commit existing blocks weren't changing anymore, but something must have escaped me. If you have a moment, could you share the markup for those test blocks where you see changes?

What I did was just create a Cover block(copy many times 😄 ) and then set different content position to each. Then test that content with your PR.

Screenshot 2023-02-02 at 9 25 52 AM

@tellthemachines
Copy link
Contributor Author

Oh, I think I see what you mean @ntsekouras. Currently, Cover block children are inheriting user agent margin styles unless they have any block- or global-level margins set. With the addition of layout, they instead get the layout margins applied, which means the first child has no margin and its siblings have a margin-top of whatever spacing value is set by the theme (or by core if the theme doesn't set any).

I'd be inclined to consider this an improvement instead of a regression 😅 because, although technically there is a change, that change makes spacing inside Cover consistent with the rest of the site, e.g. post content already has those spacing rules applied.

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

I'd be inclined to consider this an improvement instead of a regression

This is a really interesting point, I think I'm inclined to agree that by using the layout support's margin-block-start: 0 rules this is effectively a bug fix in that the positioning controls of the Cover block now work more consistently. In a test post where I tried out each of the permutations, I found it noticeable that in the center positions, with this PR applied, elements are correctly centred where they weren't before due to the paragraph's user agent margin styles, as you mention. E.g. here's a before / after of vertically centered, align right — note that in the before version, the browser default top margin of the paragraph block causes the blocks to sit too far down:

image

Similarly, it's quite noticeable when looking at top alignment:

image

Whereas, using the same pattern, the issue isn't noticeable in the bottom alignment, because the Buttons block is the lowest block visually, so doesn't have a browser default margin (it would be noticeable if the paragraph block were the lowest visually):

image

So, I think there's a compelling argument that by introducing the layout support to this block, it either fixes a bug in the behaviour of the alignment matrix, or is an enhancement to the alignment matrix, in that the positioning is now much more consistent in what it does — and likely closer to a user's expectations for how it would work.

The main problem, then, is that it is a breaking change for sites, so whether or not it is an improvement might be subjective from the perspective of a site owner. An argument in favour of landing this change even though it is a change from what's on trunk is that it looks like the change only affects sites that already opt-in to using blockGap (either directly or via appearance tools). For example, if I switch appearanceTools to false or blockGap to null, then I can get back the extra space above the paragraph:

image

On balance, I think the changes in this PR are largely positive (good default constrained layout setting, fixed behaviour of alignment matrix for sites that use blockGap), so I'd be in favour of going with this. Would it be worth gathering more feedback from folks / a design review, to confirm the approach? From my perspective it's looking good from both a functionality and code perspective.

Great work so far! 🎉

@andrewserong
Copy link
Contributor

Just one more thought, since we're opting in to the layout support, should we add support for spacing.blockGap at the same time, so that the spacing between blocks can be adjusted at the block level? Looks like it should work pretty well out of the box:

2023-02-08 16 43 37

@ntsekouras
Copy link
Contributor

I'd be inclined to consider this an improvement instead of a regression 😅 because, although technically there is a change, that change makes spacing inside Cover consistent with the rest of the site, e.g. post content already has those spacing rules applied

I agree with the part that this is an improvement, but unfortunately is also a regression 😅

We can get some more feedback here.. My opinion would be that we can land this(from the style changes perspective), but probably not in 6.2 at this point.

@tellthemachines
Copy link
Contributor Author

Thanks for the extensive testing @andrewserong !

should we add support for spacing.blockGap at the same time, so that the spacing between blocks can be adjusted at the block level?

Yes, great idea! I'll give it a go.

My opinion would be that we can land this(from the style changes perspective), but probably not in 6.2 at this point.

Oh, definitely not in 6.2 now that we're in Beta. Let's merge it in the plugin and see how it goes for a while first!

Also cc. @WordPress/gutenberg-design for feedback, and some themes folks perhaps? @carolinan @jffng @mikachan

@jameskoster
Copy link
Contributor

Seems to be working as advertised. It wasn't clear to me why I can set a wide width on children like images but not paragraphs, but that seems to be a separate thing as it occurs with Group blocks too.

Other than that, the only thing that tripped me up was this variation button:

Screenshot 2023-02-09 at 10 23 35

I don't think we need it?

Copy link
Member

@mikachan mikachan 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 testing well for me!

I agree that using the layout margins/spacing is an improvement, as this improves the Cover block positioning controls. But I also understand the change in spacing is a regression for existing users.

I also like the idea of supporting blockGap here.

I'm in favour of including this in the plugin for now and gathering more feedback that way.

@paaljoachim
Copy link
Contributor

paaljoachim commented Feb 9, 2023

This is probably a side comment but...
Layout: "The Inner blocks use content width" setting still confuses me. I have had a hard time explaining what it actually does. The description: "Nested blocks use content width with options for full and wide widths." I get a bit tripped up by the description when two widths are used in the same sentence.

To me this is one setting that needs to be re-thought. I see the result when toggling it on in the Group block when I change the Content and Wide fields but I am still not sure how it in general affects the layout of other elements outside of it.

I am hesitant in adding the above setting to the Cover block as it just feels too vague for me and difficult to really understand. When I initially began looking at this PR I thought it was related to the "Change content position". I noticed I was wrong it was more to do with the width of the content inside the Cover block then the "Change content position" setting.

Having a clearly defined "Change content position" would help a lot. Perhaps finding a way to simplify the "inner blocks use content width" toggle setting would help a lot as well. Finding a way that with a quick glance this specific setting becomes easier to understand.

@tellthemachines
Copy link
Contributor Author

Thanks for the feedback everyone!

Seems to be working as advertised. It wasn't clear to me why I can set a wide width on children like images but not paragraphs, but that seems to be a separate thing as it occurs with Group blocks too.

Yeah, I think the logic is that blocks considered "inline" like paragraphs don't have block alignment settings. It's always been like that, though perhaps it should be revisited at some point!

Other than that, the only thing that tripped me up was this variation button:

Ah yes, that was a bug 😅
Should be fixed now.

Regarding the addition of block spacing controls, it proved more complicated than expected because spacing styles output wasn't taking the multi-wrapper markup structure of Cover block into account. Because I had to jump through a few hoops to enable it, I decided to do so in a separate PR: #47952. (It's currently pointing to this one so it can be properly tested with Cover block)

@richtabor
Copy link
Member

Nice, Something to consider: while layout is toggled off (fullwidth inner blocks), then the matrix position control is a bit confusing. You can only have top, middle, bottom positioning.

CleanShot.2023-03-06.at.14.53.55.mp4

@@ -13,6 +13,7 @@ import edit from './edit';
import metadata from './block.json';
import save from './save';
import transforms from './transforms';
import variations from './variations';
Copy link
Member

Choose a reason for hiding this comment

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

Do we need variations? I don't think so, yea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do need them unfortunately. The variation here is used as a workaround to apply constrained layout to all newly added blocks, without forcing it on existing blocks, which could potentially break a lot of websites.

(Making new blocks constrained is meant to match the behaviour of Group blocks, and also mitigate the experience for hybrid themes that suddenly lose all their legacy layout styles when they add a theme.json)

@tellthemachines
Copy link
Contributor Author

Nice, Something to consider: while layout is toggled off (fullwidth inner blocks), then the matrix position control is a bit confusing. You can only have top, middle, bottom positioning.

Good point! Might be good to get some design input on that cc. @WordPress/gutenberg-design

@tellthemachines
Copy link
Contributor Author

Nice, Something to consider: while layout is toggled off (fullwidth inner blocks), then the matrix position control is a bit confusing. You can only have top, middle, bottom positioning.

Good point! Might be good to get some design input on that cc. https://github.com/orgs/WordPress/teams/gutenberg-design

Looking at this a bit closer, the behaviour with layout toggled off matches what we have in trunk, as currently the children of Cover always take up its full width. Likewise, on this branch, with layout off it's still possible to move the content around as long as it doesn't take up the full block width. For example:

withoutlayout
Trunk

withlayout
This branch

So it should be fine to keep this behaviour as is!

@richtabor
Copy link
Member

richtabor commented Mar 8, 2023

Looking at this a bit closer, the behaviour with layout toggled off matches what we have in trunk, as currently the children of Cover always take up its full width.

Yea, good point.

Copy link
Member

@richtabor richtabor left a comment

Choose a reason for hiding this comment

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

LGTM ✅

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

This looks like a good place to land it to me, too! Nice work 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Layout Layout block support, its UI controls, and style output.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Add Layout support to Cover block
8 participants