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 color tools to time to read block #49496

Merged
merged 3 commits into from
Mar 31, 2023
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 docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/post-time-to-read/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
}
},
"supports": {
"color": {
"gradients": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"html": false,
"spacing": {
"margin": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-time-to-read/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function PostTimeToReadEdit( { attributes, setAttributes, context } ) {
} }
/>
</BlockControls>
<p { ...blockProps }>{ minutesToReadString }</p>
<div { ...blockProps }>{ minutesToReadString }</div>
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-time-to-read/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<p %1$s>%2$s</p>',
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$minutes_to_read_string
);
Expand Down
8 changes: 4 additions & 4 deletions phpunit/blocks/render-post-time-to-read-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<p class="wp-block-post-time-to-read">1 minute</p>';
$expected = '<div class="wp-block-post-time-to-read">1 minute</div>';

$this->assertSame( $expected, $actual );
}
Expand All @@ -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 = '<p class="wp-block-post-time-to-read">1 minute</p>';
$expected = '<div class="wp-block-post-time-to-read">1 minute</div>';

$this->assertSame( $expected, $actual );
}
Expand All @@ -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 = '<p class="wp-block-post-time-to-read">1 minute</p>';
$expected = '<div class="wp-block-post-time-to-read">1 minute</div>';

$this->assertSame( $expected, $actual );
}
Expand All @@ -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 = '<p class="wp-block-post-time-to-read">2 minutes</p>';
$expected = '<div class="wp-block-post-time-to-read">2 minutes</div>';

$this->assertSame( $expected, $actual );
}
Expand Down