Skip to content

Commit

Permalink
Add constrained/flow layout to Cover block.
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Oct 27, 2022
1 parent 6c9c919 commit 3722eb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/cover/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
"__experimentalDefaultControls": {
"fontSize": true
}
},
"__experimentalLayout": {
"default": {
"type": "constrained"
}
}
},
"editorStyle": "wp-block-cover-editor",
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/cover/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function CoverEdit( {
hasParallax,
isDark,
isRepeated,
layout = {},
minHeight,
minHeightUnit,
alt,
Expand Down Expand Up @@ -183,6 +184,11 @@ function CoverEdit( {
fontSize: hasFontSizes ? 'large' : undefined,
} );

const defaultLayout = useSetting( 'layout' ) || {};
const usedLayout = ! layout?.type
? { ...defaultLayout, ...layout, type: 'constrained' }
: { ...defaultLayout, ...layout };

const innerBlocksProps = useInnerBlocksProps(
{
className: 'wp-block-cover__inner-container',
Expand All @@ -192,6 +198,7 @@ function CoverEdit( {
templateInsertUpdatesSelection: true,
allowedBlocks,
templateLock,
__experimentalLayout: usedLayout,
}
);

Expand Down

0 comments on commit 3722eb7

Please sign in to comment.