diff --git a/packages/block-library/src/post-author/block.json b/packages/block-library/src/post-author/block.json
index dd7a983f9761cc..58c0247bb01046 100644
--- a/packages/block-library/src/post-author/block.json
+++ b/packages/block-library/src/post-author/block.json
@@ -30,6 +30,14 @@
},
"customTextColor": {
"type": "string"
+ },
+ "bylineRatio": {
+ "type": "number",
+ "default": 0.5
+ },
+ "bioRatio": {
+ "type": "number",
+ "default": 0.7
}
},
"context": [
diff --git a/packages/block-library/src/post-author/edit.js b/packages/block-library/src/post-author/edit.js
index a9d5a66eb07089..ae5dd9f3fd0aff 100644
--- a/packages/block-library/src/post-author/edit.js
+++ b/packages/block-library/src/post-author/edit.js
@@ -16,7 +16,12 @@ import {
__experimentalUseColors,
BlockColorsStyleSelector,
} from '@wordpress/block-editor';
-import { PanelBody, SelectControl, ToggleControl } from '@wordpress/components';
+import {
+ PanelBody,
+ SelectControl,
+ ToggleControl,
+ RangeControl,
+} from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
@@ -114,6 +119,22 @@ function PostAuthorEdit( { isSelected, context, attributes, setAttributes } ) {
};
}, [ align ] );
+ const inlineStyles = useMemo( () => {
+ return {
+ bio: { fontSize: attributes.bioRatio + 'em' },
+ byline: { fontSize: attributes.bylineRatio + 'em' },
+ };
+ }, [ attributes.bioRatio, attributes.bylineRatio ] );
+
+ // Set initial ratios to use for reset values.
+ const initialAttributes = useMemo( () => {
+ const { bylineRatio, bioRatio } = attributes;
+ return {
+ bylineRatio,
+ bioRatio,
+ };
+ }, [] );
+
return (
<>
{ authorDetails?.name }
{ showBio && ( -+
{ authorDetails?.description }
) } diff --git a/packages/block-library/src/post-author/editor.scss b/packages/block-library/src/post-author/editor.scss index e57cb18ae23680..fbcaa0f8d9b925 100644 --- a/packages/block-library/src/post-author/editor.scss +++ b/packages/block-library/src/post-author/editor.scss @@ -4,7 +4,6 @@ line-height: 1.5; .wp-block-post-author__byline { - font-size: 0.5em; margin-top: 0; position: relative; font-style: normal; @@ -31,6 +30,5 @@ .wp-block-post-author__bio { margin: 0 0 $grid-unit-10; - font-size: 0.7em; } } diff --git a/packages/block-library/src/post-author/index.php b/packages/block-library/src/post-author/index.php index 2a96766c5b6bdd..8e8431699c24df 100644 --- a/packages/block-library/src/post-author/index.php +++ b/packages/block-library/src/post-author/index.php @@ -140,12 +140,16 @@ function render_block_core_post_author( $attributes, $content, $block ) { ? sprintf( ' style="%s"', esc_attr( $colors['text']['inline_styles'] ) ) : ''; + // Add inline styles for byline and bio relative font sizes. + $byline_inline_styles = sprintf( 'style="font-size: %sem"', $attributes['bylineRatio'] ); + $bio_inline_styles = sprintf( 'style="font-size: %sem"', $attributes['bioRatio'] ); + return sprintf( '