Skip to content

Commit

Permalink
Group block: Simplify variations' isActive fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jul 3, 2024
1 parent 891ef74 commit 086d822
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/block-library/src/group/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const variations = [
attributes: { layout: { type: 'constrained' } },
isDefault: true,
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
! blockAttributes.layout ||
! blockAttributes.layout?.type ||
blockAttributes.layout?.type === 'default' ||
blockAttributes.layout?.type === 'constrained',
icon: group,
},
{
Expand All @@ -25,10 +20,7 @@ const variations = [
description: __( 'Arrange blocks horizontally.' ),
attributes: { layout: { type: 'flex', flexWrap: 'nowrap' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'flex' &&
( ! blockAttributes.layout?.orientation ||
blockAttributes.layout?.orientation === 'horizontal' ),
isActive: [ 'layout.type' ],
icon: row,
},
{
Expand All @@ -37,9 +29,7 @@ const variations = [
description: __( 'Arrange blocks vertically.' ),
attributes: { layout: { type: 'flex', orientation: 'vertical' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'flex' &&
blockAttributes.layout?.orientation === 'vertical',
isActive: [ 'layout.type', 'layout.orientation' ],
icon: stack,
},
{
Expand All @@ -48,8 +38,7 @@ const variations = [
description: __( 'Arrange blocks in a grid.' ),
attributes: { layout: { type: 'grid' } },
scope: [ 'block', 'inserter', 'transform' ],
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'grid',
isActive: [ 'layout.type' ],
icon: grid,
},
];
Expand Down

0 comments on commit 086d822

Please sign in to comment.