Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block gap: Only render CSS variable if corresponding theme setting is enabled #35209

Merged
Prev Previous commit
Next Next commit
Fix linting issues in test file
  • Loading branch information
andrewserong committed Sep 30, 2021
commit 41a719782f11c6cc64fb26f22a068a8a159c0c84
17 changes: 9 additions & 8 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,17 @@ function test_get_stylesheet_skips_disabled_protected_properties() {
array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => null,
),
),
'styles' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => '1em',
),
'blocks' => array(
'blocks' => array(
'core/columns' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => '24px',
),
),
Expand All @@ -268,24 +268,25 @@ function test_get_stylesheet_renders_enabled_protected_properties() {
array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => true,
),
),
'styles' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => '1em',
),
'blocks' => array(
'blocks' => array(
'core/columns' => array(
'spacing' => array(
'spacing' => array(
'blockGap' => '24px',
),
),
),
),
)
);

$expected = 'body{--wp--style--block-gap: 1em;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }.wp-block-columns{--wp--style--block-gap: 24px;}';
$this->assertEquals( $expected, $theme_json->get_stylesheet() );
$this->assertEquals( $expected, $theme_json->get_stylesheet( 'block_styles' ) );
Expand Down