diff --git a/packages/block-editor/src/layouts/constrained.js b/packages/block-editor/src/layouts/constrained.js index 773c42e9051c51..c8c6d741199427 100644 --- a/packages/block-editor/src/layouts/constrained.js +++ b/packages/block-editor/src/layouts/constrained.js @@ -32,8 +32,10 @@ export default { inspectorControls: function DefaultLayoutInspectorControls( { layout, onChange, + layoutBlockSupport = {}, } ) { const { wideSize, contentSize, justifyContent = 'center' } = layout; + const { allowJustification = true } = layoutBlockSupport; const onJustificationChange = ( value ) => { onChange( { ...layout, @@ -117,23 +119,27 @@ export default { 'Customize the width for all elements that are assigned to the center or wide columns.' ) }

- - { justificationOptions.map( ( { value, icon, label } ) => { - return ( - - ); - } ) } - + { allowJustification && ( + + { justificationOptions.map( + ( { value, icon, label } ) => { + return ( + + ); + } + ) } + + ) } ); }, diff --git a/packages/block-library/src/cover/block.json b/packages/block-library/src/cover/block.json index 3bcc779a0f1274..b515b21e61ea38 100644 --- a/packages/block-library/src/cover/block.json +++ b/packages/block-library/src/cover/block.json @@ -109,6 +109,9 @@ "__experimentalDefaultControls": { "fontSize": true } + }, + "__experimentalLayout": { + "allowJustification": false } }, "editorStyle": "wp-block-cover-editor", diff --git a/packages/block-library/src/cover/index.js b/packages/block-library/src/cover/index.js index eb780571248be7..e6797a3b51dbe4 100644 --- a/packages/block-library/src/cover/index.js +++ b/packages/block-library/src/cover/index.js @@ -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'; const { name } = metadata; @@ -48,6 +49,7 @@ export const settings = { save, edit, deprecated, + variations, }; export const init = () => initBlock( { name, metadata, settings } ); diff --git a/packages/block-library/src/cover/variations.js b/packages/block-library/src/cover/variations.js new file mode 100644 index 00000000000000..37c04d9a3cb987 --- /dev/null +++ b/packages/block-library/src/cover/variations.js @@ -0,0 +1,20 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { cover } from '@wordpress/icons'; + +const variations = [ + { + name: 'cover', + title: __( 'Cover' ), + description: __( + 'Add an image or video with a text overlay — great for headers.' + ), + attributes: { layout: { type: 'constrained' } }, + isDefault: true, + icon: cover, + }, +]; + +export default variations; diff --git a/packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap b/packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap index 809990c313bc53..5187e574f2c7aa 100644 --- a/packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +++ b/packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap @@ -88,7 +88,7 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \

First paragraph

- +