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 Jan 31, 2023
1 parent fff6d81 commit ca7a319
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 @@ -109,6 +109,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 @@ -184,6 +185,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 @@ -195,6 +201,7 @@ function CoverEdit( {
templateInsertUpdatesSelection: true,
allowedBlocks,
templateLock,
__experimentalLayout: usedLayout,
}
);

Expand Down

0 comments on commit ca7a319

Please sign in to comment.