From 6747026f5d699ff34bddbfecb9de75fb5f8531e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 15 Jun 2020 19:22:17 +0200 Subject: [PATCH 01/10] Add defaults for padding --- packages/block-editor/src/store/defaults.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/store/defaults.js b/packages/block-editor/src/store/defaults.js index 42d043c24a135..e3774755928bb 100644 --- a/packages/block-editor/src/store/defaults.js +++ b/packages/block-editor/src/store/defaults.js @@ -131,6 +131,12 @@ export const SETTINGS_DEFAULTS = { { slug: 'full', name: __( 'Full Size' ) }, ], + padding: [ + { slug: 'small', name: __( 'Small' ), value: 4 }, + { slug: 'regular', name: __( 'Regular' ), value: 14 }, + { slug: 'large', name: __( 'Large' ), value: 23 }, + ], + // This is current max width of the block inner area // It's used to constraint image resizing and this value could be overridden later by themes maxWidth: 580, From f886e0d4370558a435eb08a92fc8023a469753d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 15 Jun 2020 19:27:43 +0200 Subject: [PATCH 02/10] Add comment about expected defaults --- packages/block-editor/README.md | 1 + packages/block-editor/src/store/defaults.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index 86371a46848c6..5815ccaceab86 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -478,6 +478,7 @@ _Properties_ - _colors_ `Array`: Palette colors - _disableCustomColors_ `boolean`: Whether or not the custom colors are disabled - _fontSizes_ `Array`: Available font sizes +- _padding_ `Array`: Available padding values - _disableCustomFontSizes_ `boolean`: Whether or not the custom font sizes are disabled - _imageSizes_ `Array`: Available image sizes - _maxWidth_ `number`: Max width to constraint resizing diff --git a/packages/block-editor/src/store/defaults.js b/packages/block-editor/src/store/defaults.js index e3774755928bb..db799c95983e5 100644 --- a/packages/block-editor/src/store/defaults.js +++ b/packages/block-editor/src/store/defaults.js @@ -16,6 +16,7 @@ export const PREFERENCES_DEFAULTS = { * @property {Array} colors Palette colors * @property {boolean} disableCustomColors Whether or not the custom colors are disabled * @property {Array} fontSizes Available font sizes + * @property {Array} padding Available padding values * @property {boolean} disableCustomFontSizes Whether or not the custom font sizes are disabled * @property {Array} imageSizes Available image sizes * @property {number} maxWidth Max width to constraint resizing From a616ba26066e25fed9d20b3ff28d5d78ecf5f051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 15 Jun 2020 19:33:05 +0200 Subject: [PATCH 03/10] Allow padding as a settings prop --- packages/editor/src/components/provider/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index e9fbe2863a665..33e97f1ec8f58 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -145,6 +145,7 @@ class EditorProvider extends Component { 'isRTL', 'maxWidth', 'onUpdateDefaultBlockStyles', + 'padding', 'styles', 'template', 'templateLock', From 37921d7b0a255984331d659f11d145bcd2965f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 15 Jun 2020 19:33:19 +0200 Subject: [PATCH 04/10] Take padding values from theme, if any --- lib/compat.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/compat.php b/lib/compat.php index 202c1345c2a8a..53f2882fb7e63 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -461,3 +461,20 @@ function gutenberg_render_block_with_assigned_block_context( $pre_render, $parse * @see WP_Block::render */ remove_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); + + +/** + * Extends block editor settings to include a list of values for padding. + * + * @param array $settings Default editor settings. + * + * @return array Filtered editor settings. + */ +function gutenberg_add_padding_presets( $settings ) { + list( $editor_padding ) = (array) get_theme_support( 'editor-spacing-padding' ); + if ( false !== $editor_padding ) { + $settings['padding'] = $editor_padding; + } + return $settings; +} +add_filter( 'block_editor_settings', 'gutenberg_add_padding_presets' ); From 54c6b10467ce53eca25bd429c189195dd08b043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 16 Jun 2020 18:37:02 +0200 Subject: [PATCH 05/10] Revert "Take padding values from theme, if any" This reverts commit cf2685fc9391fdc6479748ac53f73a3cf8f964d6. See conversation at https://github.com/WordPress/gutenberg/pull/23177#discussion_r440813497 --- lib/compat.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/compat.php b/lib/compat.php index 53f2882fb7e63..202c1345c2a8a 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -461,20 +461,3 @@ function gutenberg_render_block_with_assigned_block_context( $pre_render, $parse * @see WP_Block::render */ remove_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' ); - - -/** - * Extends block editor settings to include a list of values for padding. - * - * @param array $settings Default editor settings. - * - * @return array Filtered editor settings. - */ -function gutenberg_add_padding_presets( $settings ) { - list( $editor_padding ) = (array) get_theme_support( 'editor-spacing-padding' ); - if ( false !== $editor_padding ) { - $settings['padding'] = $editor_padding; - } - return $settings; -} -add_filter( 'block_editor_settings', 'gutenberg_add_padding_presets' ); From 115ea7230dce7c45aec62223bf7d9aead4cf20ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 16 Jun 2020 18:39:56 +0200 Subject: [PATCH 06/10] Add defaults for padding preset in global styles --- lib/experimental-default-theme.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/experimental-default-theme.json b/lib/experimental-default-theme.json index 1d1cfdabce390..ebb7e86b7c263 100644 --- a/lib/experimental-default-theme.json +++ b/lib/experimental-default-theme.json @@ -122,6 +122,11 @@ "slug": "vivid-cyan-blue-to-vivid-purple", "value": "linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)" } + ], + "padding": [ + { "slug": "small", "value": 4 }, + { "slug": "regular", "value": 14 }, + { "slug": "large", "value": 23 } ] }, "features": { From 41de55c2f272fda640d01088aad7b1e1f9ff09d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Wed, 17 Jun 2020 13:31:48 +0200 Subject: [PATCH 07/10] Make space for select control --- packages/components/src/box-control/index.js | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/components/src/box-control/index.js b/packages/components/src/box-control/index.js index 89235162c745d..727b534b0b28c 100644 --- a/packages/components/src/box-control/index.js +++ b/packages/components/src/box-control/index.js @@ -44,6 +44,7 @@ function useUniqueId( idProp ) { return idProp || id; } + export default function BoxControl( { id: idProp, inputProps = defaultInputProps, @@ -120,6 +121,17 @@ export default function BoxControl( { { label } + + + + + + + +