Skip to content

Commit

Permalink
Add constrained layout as a block variation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Mar 6, 2023
1 parent 22c8c2c commit e8af878
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/block-library/src/cover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,6 +49,7 @@ export const settings = {
save,
edit,
deprecated,
variations,
};

export const init = () => initBlock( { name, metadata, settings } );
25 changes: 25 additions & 0 deletions packages/block-library/src/cover/variations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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,
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
! blockAttributes.layout ||
! blockAttributes.layout?.type ||
blockAttributes.layout?.type === 'constrained',
icon: cover,
},
];

export default variations;

0 comments on commit e8af878

Please sign in to comment.