From ae4e7836c95af22d97e35ec295f19432a8ead3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 18:10:41 +0200 Subject: [PATCH 1/8] Centralize mappings --- lib/global-styles.php | 63 +++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 1b6d5aa6bc2c83..551cecf227d87c 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -5,6 +5,44 @@ * @package gutenberg */ +/** + * Returns the paths to get the information about a particular + * style property from the block.json or the theme.json. + */ +function gutenberg_experimental_global_styles_get_mappings() { + $mappings = array( + 'line-height' => array( + 'theme_json' => array( 'typography', 'lineHeight' ), + 'block_json' => array( '__experimentalLineHeight' ), + ), + 'font-size' => array( + 'block_json' => array( '__experimentalFontSize' ), + 'theme_json' => array( 'typography', 'fontSize' ), + ), + 'background' => array( + 'block_json' => array( '__experimentalColor', 'gradients' ), + 'theme_json' => array( 'color', 'gradient' ), + ), + 'background-color' => array( + 'block_json' => array( '__experimentalColor' ), + 'theme_json' => array( 'color', 'background' ), + ), + 'color' => array( + 'block_json' => array( '__experimentalColor' ), + 'theme_json' => array( 'color', 'text' ), + ), + '--wp--style--color--link' => array( + 'block_json' => array( '__experimentalColor', 'linkColor' ), + 'theme_json' => array( 'color', 'link' ), + ), + 'block-align' => array( + 'block_json' => array( 'align' ), + ), + ); + + return $mappings; +} + /** * Whether the current theme has a theme.json file. * @@ -269,19 +307,11 @@ function gutenberg_experimental_global_styles_get_theme() { * @return array Style features supported by the block. */ function gutenberg_experimental_global_styles_get_supported_styles( $supports ) { - $style_features = array( - '--wp--style--color--link' => array( '__experimentalColor', 'linkColor' ), - 'background-color' => array( '__experimentalColor' ), - 'background' => array( '__experimentalColor', 'gradients' ), - 'block-align' => array( 'align' ), - 'color' => array( '__experimentalColor' ), - 'font-size' => array( '__experimentalFontSize' ), - 'line-height' => array( '__experimentalLineHeight' ), - ); + $mappings = gutenberg_experimental_global_styles_get_mappings(); $supported_features = array(); - foreach ( $style_features as $style_feature => $path ) { - if ( gutenberg_experimental_get( $supports, $path ) ) { + foreach ( $mappings as $style_feature => $path ) { + if ( gutenberg_experimental_get( $supports, $path['block_json'] ) ) { $supported_features[] = $style_feature; } } @@ -370,19 +400,12 @@ function gutenberg_experimental_global_styles_get_block_data() { * @return array Containing a set of css rules. */ function gutenberg_experimental_global_styles_flatten_styles_tree( $styles ) { - $mappings = array( - 'line-height' => array( 'typography', 'lineHeight' ), - 'font-size' => array( 'typography', 'fontSize' ), - 'background' => array( 'color', 'gradient' ), - 'background-color' => array( 'color', 'background' ), - 'color' => array( 'color', 'text' ), - '--wp--style--color--link' => array( 'color', 'link' ), - ); + $mappings = gutenberg_experimental_global_styles_get_mappings(); $result = array(); foreach ( $mappings as $key => $path ) { - $value = gutenberg_experimental_get( $styles, $path, null ); + $value = gutenberg_experimental_get( $styles, $path['theme_json'], null ); if ( null !== $value ) { $result[ $key ] = $value; } From 7c1e46a3431567db6511aa78c3d9bb7b9e114136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 18:38:05 +0200 Subject: [PATCH 2/8] Organize style props within __experimentalStyles --- packages/block-library/src/columns/block.json | 8 ++++++++ packages/block-library/src/group/block.json | 8 ++++++++ packages/block-library/src/heading/block.json | 11 +++++++++++ packages/block-library/src/media-text/block.json | 8 ++++++++ packages/block-library/src/paragraph/block.json | 11 +++++++++++ packages/block-library/src/post-author/block.json | 14 +++++++++++++- .../src/post-comments-count/block.json | 13 ++++++++++++- .../src/post-comments-form/block.json | 14 +++++++++++++- .../block-library/src/post-comments/block.json | 14 +++++++++++++- packages/block-library/src/post-date/block.json | 13 ++++++++++++- packages/block-library/src/post-excerpt/block.json | 14 +++++++++++++- packages/block-library/src/post-title/block.json | 11 +++++++++++ packages/block-library/src/site-tagline/block.json | 13 ++++++++++++- packages/block-library/src/site-title/block.json | 13 ++++++++++++- 14 files changed, 157 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/columns/block.json b/packages/block-library/src/columns/block.json index 0a84a4a35d7812..c084a44a893241 100644 --- a/packages/block-library/src/columns/block.json +++ b/packages/block-library/src/columns/block.json @@ -17,6 +17,14 @@ "__experimentalColor": { "gradients": true, "linkColor": true + }, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + } } } } diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json index 1e32b1443cbc85..133ee313d79405 100644 --- a/packages/block-library/src/group/block.json +++ b/packages/block-library/src/group/block.json @@ -18,6 +18,14 @@ "__experimentalColor": { "gradients": true, "linkColor": true + }, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + } } } } diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index fd03a4487ee5aa..7534b647148299 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -36,6 +36,17 @@ "core/heading/h5": "h5", "core/heading/h6": "h6" }, + "__experimentalStyles": { + "color": { + "background": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + }, "__unstablePasteTextInline": true } } diff --git a/packages/block-library/src/media-text/block.json b/packages/block-library/src/media-text/block.json index 012e6c253280df..125d05df94cbb0 100644 --- a/packages/block-library/src/media-text/block.json +++ b/packages/block-library/src/media-text/block.json @@ -88,6 +88,14 @@ "__experimentalColor": { "gradients": true, "linkColor": true + }, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + } } } } diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index 24df851e88011b..aa9e8ef062e575 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -41,6 +41,17 @@ } }, "__experimentalSelector": "p", + "__experimentalStyles": { + "color": { + "background": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + }, "__unstablePasteTextInline": true } } diff --git a/packages/block-library/src/post-author/block.json b/packages/block-library/src/post-author/block.json index 3e788777dec81d..a6906eef491a3a 100644 --- a/packages/block-library/src/post-author/block.json +++ b/packages/block-library/src/post-author/block.json @@ -32,6 +32,18 @@ "gradients": true, "linkColor": true }, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-comments-count/block.json b/packages/block-library/src/post-comments-count/block.json index 5908f13b721c76..cd3ddfab6ed314 100644 --- a/packages/block-library/src/post-comments-count/block.json +++ b/packages/block-library/src/post-comments-count/block.json @@ -16,6 +16,17 @@ "gradients": true }, "__experimentalFontSize": true, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-comments-form/block.json b/packages/block-library/src/post-comments-form/block.json index c0e131b83b231b..a5bd0a04441273 100644 --- a/packages/block-library/src/post-comments-form/block.json +++ b/packages/block-library/src/post-comments-form/block.json @@ -18,6 +18,18 @@ "linkColor": true }, "__experimentalFontSize": true, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-comments/block.json b/packages/block-library/src/post-comments/block.json index 51dbb5c22dcbcc..cfc6d4cc2f5ad0 100644 --- a/packages/block-library/src/post-comments/block.json +++ b/packages/block-library/src/post-comments/block.json @@ -22,6 +22,18 @@ "gradients": true, "linkColor": true }, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-date/block.json b/packages/block-library/src/post-date/block.json index 872bf705c01162..f9825b1214dcec 100644 --- a/packages/block-library/src/post-date/block.json +++ b/packages/block-library/src/post-date/block.json @@ -20,6 +20,17 @@ "gradients": true }, "__experimentalFontSize": true, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-excerpt/block.json b/packages/block-library/src/post-excerpt/block.json index 28952d268ff922..1e124702e37eea 100644 --- a/packages/block-library/src/post-excerpt/block.json +++ b/packages/block-library/src/post-excerpt/block.json @@ -29,6 +29,18 @@ "gradients": true, "linkColor": true }, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "link": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/post-title/block.json b/packages/block-library/src/post-title/block.json index ec3cad1f435ae8..cd354e615a052f 100644 --- a/packages/block-library/src/post-title/block.json +++ b/packages/block-library/src/post-title/block.json @@ -30,6 +30,17 @@ "core/post-title/h5": "h5", "core/post-title/h6": "h6", "core/post-title/p": "p" + }, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } } } } diff --git a/packages/block-library/src/site-tagline/block.json b/packages/block-library/src/site-tagline/block.json index b0b4d5ab95b0b0..4748e0d2d11cdc 100644 --- a/packages/block-library/src/site-tagline/block.json +++ b/packages/block-library/src/site-tagline/block.json @@ -13,6 +13,17 @@ "gradients": true }, "__experimentalFontSize": true, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } diff --git a/packages/block-library/src/site-title/block.json b/packages/block-library/src/site-title/block.json index 4817093296629a..d07e31fffce121 100644 --- a/packages/block-library/src/site-title/block.json +++ b/packages/block-library/src/site-title/block.json @@ -17,6 +17,17 @@ "gradients": true }, "__experimentalFontSize": true, - "__experimentalLineHeight": true + "__experimentalLineHeight": true, + "__experimentalStyles": { + "color": { + "background": true, + "gradient": true, + "text": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + } } } From bd3cce8f5116ece42472dedd54828a3146361421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 19:15:05 +0200 Subject: [PATCH 3/8] Global Styles: take data from __experimentalStyles key --- lib/global-styles.php | 52 ++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 551cecf227d87c..88695b4067846b 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -10,37 +10,14 @@ * style property from the block.json or the theme.json. */ function gutenberg_experimental_global_styles_get_mappings() { - $mappings = array( - 'line-height' => array( - 'theme_json' => array( 'typography', 'lineHeight' ), - 'block_json' => array( '__experimentalLineHeight' ), - ), - 'font-size' => array( - 'block_json' => array( '__experimentalFontSize' ), - 'theme_json' => array( 'typography', 'fontSize' ), - ), - 'background' => array( - 'block_json' => array( '__experimentalColor', 'gradients' ), - 'theme_json' => array( 'color', 'gradient' ), - ), - 'background-color' => array( - 'block_json' => array( '__experimentalColor' ), - 'theme_json' => array( 'color', 'background' ), - ), - 'color' => array( - 'block_json' => array( '__experimentalColor' ), - 'theme_json' => array( 'color', 'text' ), - ), - '--wp--style--color--link' => array( - 'block_json' => array( '__experimentalColor', 'linkColor' ), - 'theme_json' => array( 'color', 'link' ), - ), - 'block-align' => array( - 'block_json' => array( 'align' ), - ), + return array( + 'line-height' => array( 'typography', 'lineHeight' ), + 'font-size' => array( 'typography', 'fontSize' ), + 'background' => array( 'color', 'gradient' ), + 'background-color' => array( 'color', 'background' ), + 'color' => array( 'color', 'text' ), + '--wp--style--color--link' => array( 'color', 'link' ) ); - - return $mappings; } /** @@ -307,11 +284,20 @@ function gutenberg_experimental_global_styles_get_theme() { * @return array Style features supported by the block. */ function gutenberg_experimental_global_styles_get_supported_styles( $supports ) { - $mappings = gutenberg_experimental_global_styles_get_mappings(); + $mappings = array_merge( + gutenberg_experimental_global_styles_get_mappings(), + // TODO: remove from here and access directly from lib/blocks.php + array( + 'block-align' => array( 'align' ) + ) + ); $supported_features = array(); foreach ( $mappings as $style_feature => $path ) { - if ( gutenberg_experimental_get( $supports, $path['block_json'] ) ) { + if ( gutenberg_experimental_get( + $supports, + array_merge( array( '__experimentalStyles' ) , $path ) + ) ) { $supported_features[] = $style_feature; } } @@ -405,7 +391,7 @@ function gutenberg_experimental_global_styles_flatten_styles_tree( $styles ) { $result = array(); foreach ( $mappings as $key => $path ) { - $value = gutenberg_experimental_get( $styles, $path['theme_json'], null ); + $value = gutenberg_experimental_get( $styles, $path, null ); if ( null !== $value ) { $result[ $key ] = $value; } From 9ad99006f901a1dbe828dc890702d93b1ad57ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 19:24:46 +0200 Subject: [PATCH 4/8] Migrate styles test to new __experimentalStyles key --- phpunit/class-block-supported-styles-test.php | 98 ++++++++++++++----- 1 file changed, 74 insertions(+), 24 deletions(-) diff --git a/phpunit/class-block-supported-styles-test.php b/phpunit/class-block-supported-styles-test.php index c4596be98e9ca1..da910bcc7e17ef 100644 --- a/phpunit/class-block-supported-styles-test.php +++ b/phpunit/class-block-supported-styles-test.php @@ -95,7 +95,12 @@ function test_named_color_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'text' => true, + ) + ), ), 'render_callback' => true, ); @@ -127,7 +132,12 @@ function test_custom_color_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'text' => true, + ) + ), ), 'render_callback' => true, ); @@ -164,8 +174,12 @@ function test_named_link_color_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => array( - 'linkColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'link' => true, + 'text' => true, + ) ), ), 'render_callback' => true, @@ -195,8 +209,12 @@ function test_custom_link_color_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => array( - 'linkColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'link' => true, + 'text' => true, + ) ), ), 'render_callback' => true, @@ -226,8 +244,12 @@ function test_named_gradient_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => array( - 'gradients' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'gradient' => true, + 'text' => true, + ) ), ), 'render_callback' => true, @@ -257,8 +279,12 @@ function test_custom_gradient_support() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => array( - 'gradients' => true, + '__experimentalStyles' => array( + 'color' => array( + 'background' => true, + 'gradient' => true, + 'text' => true, + ) ), ), 'render_callback' => true, @@ -324,7 +350,11 @@ function test_named_font_size() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalFontSize' => true, + '__experimentalStyles' => array( + 'typography' => array( + 'fontSize' => true + ), + ), ), 'render_callback' => true, ); @@ -353,7 +383,11 @@ function test_custom_font_size() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalFontSize' => true, + '__experimentalStyles' => array( + 'typography' => array( + 'fontSize' => true + ), + ), ), 'render_callback' => true, ); @@ -410,7 +444,11 @@ function test_line_height() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalLineHeight' => true, + '__experimentalStyles' => array( + 'typography' => array( + 'lineHeight' => true + ), + ), ), 'render_callback' => true, ); @@ -522,12 +560,16 @@ function test_all_supported() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalColor' => array( - 'gradients' => true, - 'linkColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'gradient' => true, + 'link' => true, + ), + 'typography' => array( + 'fontSize' => true, + 'lineHeight' => true, + ), ), - '__experimentalFontSize' => true, - '__experimentalLineHeight' => true, 'align' => true, ), 'render_callback' => true, @@ -570,7 +612,11 @@ function test_one_supported() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - '__experimentalFontSize' => true, + '__experimentalStyles' => array( + 'typography' => array( + 'fontSize' => true + ), + ), ), 'render_callback' => true, ); @@ -612,12 +658,16 @@ function test_render_callback_required() { 'attributes' => array(), 'supports' => array( 'align' => true, - '__experimentalColor' => array( - 'gradients' => true, - 'linkColor' => true, + '__experimentalStyles' => array( + 'color' => array( + 'gradient' => true, + 'link' => true, + ), + 'typography' => array( + 'fontSize' => true, + 'lineHeight' => true, + ), ), - '__experimentalFontSize' => true, - '__experimentalLineHeight' => true, ), ); $this->register_block_type( 'core/example', $block_type_settings ); From 9df7f240d6cdc77c6081f1a0c7fee9f7294b6b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 19:54:03 +0200 Subject: [PATCH 5/8] Migrate hooks to use __experimentalStyles --- packages/block-editor/src/hooks/color.js | 6 +++--- packages/block-editor/src/hooks/font-size.js | 2 +- packages/block-editor/src/hooks/line-height.js | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/hooks/color.js b/packages/block-editor/src/hooks/color.js index 5cc3fb51c6c8b9..de589c3fe43f99 100644 --- a/packages/block-editor/src/hooks/color.js +++ b/packages/block-editor/src/hooks/color.js @@ -30,7 +30,7 @@ import { import { cleanEmptyObject } from './utils'; import ColorPanel from './color-panel'; -export const COLOR_SUPPORT_KEY = '__experimentalColor'; +export const COLOR_SUPPORT_KEY = '__experimentalStyles.color'; const hasColorSupport = ( blockType ) => Platform.OS === 'web' && hasBlockSupport( blockType, COLOR_SUPPORT_KEY ); @@ -42,7 +42,7 @@ const hasLinkColorSupport = ( blockType ) => { const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY ); - return isObject( colorSupport ) && !! colorSupport.linkColor; + return isObject( colorSupport ) && !! colorSupport.link; }; const hasGradientSupport = ( blockType ) => { @@ -52,7 +52,7 @@ const hasGradientSupport = ( blockType ) => { const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY ); - return isObject( colorSupport ) && !! colorSupport.gradients; + return isObject( colorSupport ) && !! colorSupport.gradient; }; /** diff --git a/packages/block-editor/src/hooks/font-size.js b/packages/block-editor/src/hooks/font-size.js index 08b3b6c4df32db..6dc4a65a23e71a 100644 --- a/packages/block-editor/src/hooks/font-size.js +++ b/packages/block-editor/src/hooks/font-size.js @@ -18,7 +18,7 @@ import { import { cleanEmptyObject } from './utils'; import { createHigherOrderComponent } from '@wordpress/compose'; -export const FONT_SIZE_SUPPORT_KEY = '__experimentalFontSize'; +export const FONT_SIZE_SUPPORT_KEY = '__experimentalStyles.typography.fontSize'; /** * Filters registered block settings, extending attributes to include diff --git a/packages/block-editor/src/hooks/line-height.js b/packages/block-editor/src/hooks/line-height.js index 8881fdbbcb17f0..9121624b959593 100644 --- a/packages/block-editor/src/hooks/line-height.js +++ b/packages/block-editor/src/hooks/line-height.js @@ -10,7 +10,8 @@ import { useSelect } from '@wordpress/data'; import LineHeightControl from '../components/line-height-control'; import { cleanEmptyObject } from './utils'; -export const LINE_HEIGHT_SUPPORT_KEY = '__experimentalLineHeight'; +export const LINE_HEIGHT_SUPPORT_KEY = + '__experimentalStyles.typography.lineHeight'; /** * Inspector control panel containing the line height related configuration From 96e4c33c09cb81cecb32020061dc24ad80cd9220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 20:09:59 +0200 Subject: [PATCH 6/8] Remove old support keys --- packages/block-library/src/columns/block.json | 4 ---- packages/block-library/src/group/block.json | 4 ---- packages/block-library/src/heading/block.json | 5 ----- packages/block-library/src/media-text/block.json | 4 ---- packages/block-library/src/paragraph/block.json | 5 ----- packages/block-library/src/post-author/block.json | 6 ------ packages/block-library/src/post-comments-count/block.json | 5 ----- packages/block-library/src/post-comments-form/block.json | 6 ------ packages/block-library/src/post-comments/block.json | 6 ------ packages/block-library/src/post-date/block.json | 5 ----- packages/block-library/src/post-excerpt/block.json | 6 ------ packages/block-library/src/post-title/block.json | 5 ----- packages/block-library/src/site-tagline/block.json | 5 ----- packages/block-library/src/site-title/block.json | 5 ----- 14 files changed, 71 deletions(-) diff --git a/packages/block-library/src/columns/block.json b/packages/block-library/src/columns/block.json index c084a44a893241..cfd820b7fe2614 100644 --- a/packages/block-library/src/columns/block.json +++ b/packages/block-library/src/columns/block.json @@ -14,10 +14,6 @@ ], "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json index 133ee313d79405..bb3d3da9526572 100644 --- a/packages/block-library/src/group/block.json +++ b/packages/block-library/src/group/block.json @@ -15,10 +15,6 @@ "anchor": true, "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index 7534b647148299..29a961e61a1801 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -23,11 +23,6 @@ "anchor": true, "className": false, "lightBlockWrapper": true, - "__experimentalColor": { - "linkColor": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalSelector": { "core/heading/h1": "h1", "core/heading/h2": "h2", diff --git a/packages/block-library/src/media-text/block.json b/packages/block-library/src/media-text/block.json index 125d05df94cbb0..fb023dc61486b3 100644 --- a/packages/block-library/src/media-text/block.json +++ b/packages/block-library/src/media-text/block.json @@ -85,10 +85,6 @@ ], "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index aa9e8ef062e575..efc7b08fe67f53 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -30,11 +30,6 @@ "anchor": true, "className": false, "lightBlockWrapper": true, - "__experimentalColor": { - "linkColor": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalFeatures": { "typography": { "dropCap": true diff --git a/packages/block-library/src/post-author/block.json b/packages/block-library/src/post-author/block.json index a6906eef491a3a..fc347afbccbc3c 100644 --- a/packages/block-library/src/post-author/block.json +++ b/packages/block-library/src/post-author/block.json @@ -27,12 +27,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalFontSize": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-comments-count/block.json b/packages/block-library/src/post-comments-count/block.json index cd3ddfab6ed314..ce086942f145e3 100644 --- a/packages/block-library/src/post-comments-count/block.json +++ b/packages/block-library/src/post-comments-count/block.json @@ -12,11 +12,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-comments-form/block.json b/packages/block-library/src/post-comments-form/block.json index a5bd0a04441273..dc2403b470032f 100644 --- a/packages/block-library/src/post-comments-form/block.json +++ b/packages/block-library/src/post-comments-form/block.json @@ -13,12 +13,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-comments/block.json b/packages/block-library/src/post-comments/block.json index cfc6d4cc2f5ad0..7c83b06b344e3b 100644 --- a/packages/block-library/src/post-comments/block.json +++ b/packages/block-library/src/post-comments/block.json @@ -17,12 +17,6 @@ "wide", "full" ], - "__experimentalFontSize": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-date/block.json b/packages/block-library/src/post-date/block.json index f9825b1214dcec..74a20b4622238f 100644 --- a/packages/block-library/src/post-date/block.json +++ b/packages/block-library/src/post-date/block.json @@ -16,11 +16,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-excerpt/block.json b/packages/block-library/src/post-excerpt/block.json index 1e124702e37eea..8d57fa9443de22 100644 --- a/packages/block-library/src/post-excerpt/block.json +++ b/packages/block-library/src/post-excerpt/block.json @@ -24,12 +24,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalFontSize": true, - "__experimentalColor": { - "gradients": true, - "linkColor": true - }, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/post-title/block.json b/packages/block-library/src/post-title/block.json index cd354e615a052f..0f709f58d18820 100644 --- a/packages/block-library/src/post-title/block.json +++ b/packages/block-library/src/post-title/block.json @@ -17,11 +17,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalSelector": { "core/post-title/h1": "h1", "core/post-title/h2": "h2", diff --git a/packages/block-library/src/site-tagline/block.json b/packages/block-library/src/site-tagline/block.json index 4748e0d2d11cdc..2701b500214b4e 100644 --- a/packages/block-library/src/site-tagline/block.json +++ b/packages/block-library/src/site-tagline/block.json @@ -9,11 +9,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, diff --git a/packages/block-library/src/site-title/block.json b/packages/block-library/src/site-title/block.json index d07e31fffce121..ab054e4d39f033 100644 --- a/packages/block-library/src/site-title/block.json +++ b/packages/block-library/src/site-title/block.json @@ -13,11 +13,6 @@ "supports": { "html": false, "lightBlockWrapper": true, - "__experimentalColor": { - "gradients": true - }, - "__experimentalFontSize": true, - "__experimentalLineHeight": true, "__experimentalStyles": { "color": { "background": true, From 258ebcdb545bc75db9e99ed8d2b101f5497fd49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 20:40:24 +0200 Subject: [PATCH 7/8] Make linter happy --- lib/global-styles.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 88695b4067846b..c9f0845bfdfb65 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -16,7 +16,7 @@ function gutenberg_experimental_global_styles_get_mappings() { 'background' => array( 'color', 'gradient' ), 'background-color' => array( 'color', 'background' ), 'color' => array( 'color', 'text' ), - '--wp--style--color--link' => array( 'color', 'link' ) + '--wp--style--color--link' => array( 'color', 'link' ), ); } @@ -286,18 +286,15 @@ function gutenberg_experimental_global_styles_get_theme() { function gutenberg_experimental_global_styles_get_supported_styles( $supports ) { $mappings = array_merge( gutenberg_experimental_global_styles_get_mappings(), - // TODO: remove from here and access directly from lib/blocks.php + // TODO: remove from here and access directly from lib/blocks.php. array( - 'block-align' => array( 'align' ) + 'block-align' => array( 'align' ), ) ); $supported_features = array(); foreach ( $mappings as $style_feature => $path ) { - if ( gutenberg_experimental_get( - $supports, - array_merge( array( '__experimentalStyles' ) , $path ) - ) ) { + if ( gutenberg_experimental_get( $supports, array_merge( array( '__experimentalStyles' ), $path ) ) ) { $supported_features[] = $style_feature; } } From 71a5978c42bc21f61fb466f0ca9f68782887da8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 2 Aug 2020 21:46:33 +0200 Subject: [PATCH 8/8] Make linter happy --- phpunit/class-block-supported-styles-test.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/phpunit/class-block-supported-styles-test.php b/phpunit/class-block-supported-styles-test.php index da910bcc7e17ef..3c44876601f560 100644 --- a/phpunit/class-block-supported-styles-test.php +++ b/phpunit/class-block-supported-styles-test.php @@ -99,7 +99,7 @@ function test_named_color_support() { 'color' => array( 'background' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -136,7 +136,7 @@ function test_custom_color_support() { 'color' => array( 'background' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -179,7 +179,7 @@ function test_named_link_color_support() { 'background' => true, 'link' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -214,7 +214,7 @@ function test_custom_link_color_support() { 'background' => true, 'link' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -249,7 +249,7 @@ function test_named_gradient_support() { 'background' => true, 'gradient' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -284,7 +284,7 @@ function test_custom_gradient_support() { 'background' => true, 'gradient' => true, 'text' => true, - ) + ), ), ), 'render_callback' => true, @@ -352,7 +352,7 @@ function test_named_font_size() { 'supports' => array( '__experimentalStyles' => array( 'typography' => array( - 'fontSize' => true + 'fontSize' => true, ), ), ), @@ -385,7 +385,7 @@ function test_custom_font_size() { 'supports' => array( '__experimentalStyles' => array( 'typography' => array( - 'fontSize' => true + 'fontSize' => true, ), ), ), @@ -446,7 +446,7 @@ function test_line_height() { 'supports' => array( '__experimentalStyles' => array( 'typography' => array( - 'lineHeight' => true + 'lineHeight' => true, ), ), ), @@ -563,14 +563,14 @@ function test_all_supported() { '__experimentalStyles' => array( 'color' => array( 'gradient' => true, - 'link' => true, + 'link' => true, ), 'typography' => array( 'fontSize' => true, 'lineHeight' => true, ), ), - 'align' => true, + 'align' => true, ), 'render_callback' => true, ); @@ -614,7 +614,7 @@ function test_one_supported() { 'supports' => array( '__experimentalStyles' => array( 'typography' => array( - 'fontSize' => true + 'fontSize' => true, ), ), ), @@ -657,7 +657,7 @@ function test_render_callback_required() { $block_type_settings = array( 'attributes' => array(), 'supports' => array( - 'align' => true, + 'align' => true, '__experimentalStyles' => array( 'color' => array( 'gradient' => true,