From cc96f74a40b204c8960641c4c0d9076d7a5102e9 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 31 Mar 2023 10:19:57 +0800 Subject: [PATCH 1/3] Add color tools to time to read block --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/post-time-to-read/block.json | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index e5b524c685086..a2923ee498143 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -590,7 +590,7 @@ Show minutes required to finish reading the post. ([Source](https://github.com/W - **Name:** core/post-time-to-read - **Category:** theme -- **Supports:** spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** textAlign ## Post Title diff --git a/packages/block-library/src/post-time-to-read/block.json b/packages/block-library/src/post-time-to-read/block.json index 20313744c343e..2b7d7936094f7 100644 --- a/packages/block-library/src/post-time-to-read/block.json +++ b/packages/block-library/src/post-time-to-read/block.json @@ -14,6 +14,13 @@ } }, "supports": { + "color": { + "gradients": true, + "__experimentalDefaultControls": { + "background": true, + "text": true + } + }, "html": false, "spacing": { "margin": true, From 588d46550c448399d63a1e092bbac1411c5cec17 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 31 Mar 2023 10:55:31 +0800 Subject: [PATCH 2/3] Make the block element a `
` --- packages/block-library/src/post-time-to-read/edit.js | 2 +- packages/block-library/src/post-time-to-read/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/post-time-to-read/edit.js b/packages/block-library/src/post-time-to-read/edit.js index b9092c69952b7..1689a6da71a5a 100644 --- a/packages/block-library/src/post-time-to-read/edit.js +++ b/packages/block-library/src/post-time-to-read/edit.js @@ -93,7 +93,7 @@ function PostTimeToReadEdit( { attributes, setAttributes, context } ) { } } /> -

{ minutesToReadString }

+
{ minutesToReadString }
); } diff --git a/packages/block-library/src/post-time-to-read/index.php b/packages/block-library/src/post-time-to-read/index.php index 07761e5e75904..03a745d20e642 100644 --- a/packages/block-library/src/post-time-to-read/index.php +++ b/packages/block-library/src/post-time-to-read/index.php @@ -42,7 +42,7 @@ function render_block_core_post_time_to_read( $attributes, $content, $block ) { $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); return sprintf( - '

%2$s

', + '
%2$s
', $wrapper_attributes, $minutes_to_read_string ); From 7fca9e463677b4582f78a05ba71ad913b71b827f Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 31 Mar 2023 11:29:46 +0800 Subject: [PATCH 3/3] Update tests to expect a div instead of a paragraph --- phpunit/blocks/render-post-time-to-read-test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpunit/blocks/render-post-time-to-read-test.php b/phpunit/blocks/render-post-time-to-read-test.php index abca2daeeeaeb..344b3fe0c71c9 100644 --- a/phpunit/blocks/render-post-time-to-read-test.php +++ b/phpunit/blocks/render-post-time-to-read-test.php @@ -114,7 +114,7 @@ public function test_no_content_post() { $block = new WP_Block( $parsed_block, $context ); $actual = gutenberg_render_block_core_post_time_to_read( $attributes, '', $block ); - $expected = '

1 minute

'; + $expected = '
1 minute
'; $this->assertSame( $expected, $actual ); } @@ -136,7 +136,7 @@ public function test_less_than_one_minute_post() { $block = new WP_Block( $parsed_block, $context ); $actual = gutenberg_render_block_core_post_time_to_read( $attributes, '', $block ); - $expected = '

1 minute

'; + $expected = '
1 minute
'; $this->assertSame( $expected, $actual ); } @@ -158,7 +158,7 @@ public function test_one_minute_post() { $block = new WP_Block( $parsed_block, $context ); $actual = gutenberg_render_block_core_post_time_to_read( $attributes, '', $block ); - $expected = '

1 minute

'; + $expected = '
1 minute
'; $this->assertSame( $expected, $actual ); } @@ -180,7 +180,7 @@ public function test_two_minutes_post() { $block = new WP_Block( $parsed_block, $context ); $actual = gutenberg_render_block_core_post_time_to_read( $attributes, '', $block ); - $expected = '

2 minutes

'; + $expected = '
2 minutes
'; $this->assertSame( $expected, $actual ); }