Skip to content

Commit

Permalink
Make grid layout Group variation an experiment. (#49359)
Browse files Browse the repository at this point in the history
* Make grid layout Group variation an experiment.

* Update packages/block-library/src/group/variations.js

optional chaining for window

Co-authored-by: Andrew Serong <[email protected]>

---------

Co-authored-by: Andrew Serong <[email protected]>
  • Loading branch information
tellthemachines and andrewserong authored Mar 27, 2023
1 parent 247579e commit 57f0bb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ function gutenberg_enable_experiments() {
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-color-randomizer', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableColorRandomizer = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-group-grid-variation', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGroupGridVariation = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_experiments' );
12 changes: 12 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-group-grid-variation',
__( 'Grid variation for Group block ', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test the Grid layout type as a new variation of Group block.', 'gutenberg' ),
'id' => 'gutenberg-group-grid-variation',
)
);

register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
9 changes: 6 additions & 3 deletions packages/block-library/src/group/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ const variations = [
blockAttributes.layout?.orientation === 'vertical',
icon: stack,
},
{
];

if ( window?.__experimentalEnableGroupGridVariation ) {
variations.push( {
name: 'group-grid',
title: __( 'Grid' ),
description: __( 'Arrange blocks in a grid.' ),
Expand All @@ -51,7 +54,7 @@ const variations = [
isActive: ( blockAttributes ) =>
blockAttributes.layout?.type === 'grid',
icon: grid,
},
];
} );
}

export default variations;

0 comments on commit 57f0bb8

Please sign in to comment.