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

Add the percent unit to the default units in Core #33468

Merged
merged 3 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ public static function get_from_editor_settings( $settings ) {
$theme_settings['settings']['spacing'] = array();
}
$theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ?
array( 'px', 'em', 'rem', 'vh', 'vw' ) :
array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) :
$settings['enableCustomUnits'];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/experimental-default-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"spacing": {
"customMargin": false,
"customPadding": false,
"units": [ "px", "em", "rem", "vh", "vw" ]
"units": [ "px", "em", "rem", "vh", "vw", "%" ]
},
"border": {
"customColor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const deprecatedFlags = {
}

if ( settings.enableCustomUnits === true ) {
return [ 'px', 'em', 'rem', 'vh', 'vw' ];
return [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];
}

return settings.enableCustomUnits;
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ function test_get_from_editor_settings() {
),
),
'spacing' => array(
'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ),
'units' => array( 'px', 'em', 'rem', 'vh', 'vw', '%' ),
),
'typography' => array(
'customFontSize' => false,
Expand Down Expand Up @@ -1578,7 +1578,7 @@ function test_get_editor_settings_custom_units_can_be_enabled() {
$input = gutenberg_get_default_block_editor_settings();

$expected = array(
'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ),
'units' => array( 'px', 'em', 'rem', 'vh', 'vw', '%' ),
'customPadding' => false,
);

Expand Down