From 9b9030810d5817e73f523a42161c2e355e7f5b50 Mon Sep 17 00:00:00 2001 From: David Szabo Date: Mon, 24 Aug 2020 11:35:28 +0200 Subject: [PATCH 1/3] Restore level toolbar --- packages/block-library/CHANGELOG.md | 4 ++ packages/block-library/src/site-title/edit.js | 47 ------------------- .../src/site-title/edit/index.js | 35 +++++++++++--- 3 files changed, 32 insertions(+), 54 deletions(-) delete mode 100644 packages/block-library/src/site-title/edit.js diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index 8df5040d7a7fa..e65910995ae21 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New Features + +- Add level controls to Site Title block + ## 2.12.0 (2020-01-13) ### Bug Fixes diff --git a/packages/block-library/src/site-title/edit.js b/packages/block-library/src/site-title/edit.js deleted file mode 100644 index d3553f75888bf..0000000000000 --- a/packages/block-library/src/site-title/edit.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; - -/** - * WordPress dependencies - */ -import { useEntityProp } from '@wordpress/core-data'; -import { __ } from '@wordpress/i18n'; -import { - RichText, - AlignmentToolbar, - BlockControls, - __experimentalBlock as Block, -} from '@wordpress/block-editor'; - -export default function SiteTitleEdit( { attributes, setAttributes } ) { - const { level, textAlign } = attributes; - const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' ); - const tagName = 0 === level ? 'p' : 'h' + level; - - return ( - <> - - { - setAttributes( { textAlign: nextAlign } ); - } } - /> - - - - - ); -} diff --git a/packages/block-library/src/site-title/edit/index.js b/packages/block-library/src/site-title/edit/index.js index a44629f7edf21..8c9fd338551c1 100644 --- a/packages/block-library/src/site-title/edit/index.js +++ b/packages/block-library/src/site-title/edit/index.js @@ -1,24 +1,40 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ import { useEntityProp } from '@wordpress/core-data'; -import { BlockControls, RichText } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; +import { + RichText, + AlignmentToolbar, + BlockControls, + __experimentalBlock as Block, +} from '@wordpress/block-editor'; /** * Internal dependencies */ import LevelToolbar from './level-toolbar'; -export default function SiteTitleEdit( { - attributes: { level }, - setAttributes, -} ) { +export default function SiteTitleEdit( { attributes, setAttributes } ) { + const { level, textAlign } = attributes; const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' ); - const tagName = level === 0 ? 'p' : `h${ level }`; + const tagName = 0 === level ? 'p' : `h${ level }`; + return ( <> + { + setAttributes( { textAlign: nextAlign } ); + } } + /> + @@ -26,12 +42,17 @@ export default function SiteTitleEdit( { } /> + ); From ffa2aa239789b8afd05e604c6e8243c6160b4ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Szab=C3=B3?= Date: Tue, 25 Aug 2020 09:13:16 +0200 Subject: [PATCH 2/3] Make changelog less confusing Co-authored-by: Bernie Reiter --- packages/block-library/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index e65910995ae21..0160e0d59a3ab 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -4,7 +4,7 @@ ### New Features -- Add level controls to Site Title block +- Add heading level controls to Site Title block. ## 2.12.0 (2020-01-13) From edf386f39d49cf37aeb0de4c5d5d7965261822e7 Mon Sep 17 00:00:00 2001 From: David Szabo Date: Tue, 25 Aug 2020 10:16:09 +0200 Subject: [PATCH 3/3] Reverse expression to avoid Yoda condition --- packages/block-library/src/site-title/edit/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/site-title/edit/index.js b/packages/block-library/src/site-title/edit/index.js index 8c9fd338551c1..3079ced37d6a6 100644 --- a/packages/block-library/src/site-title/edit/index.js +++ b/packages/block-library/src/site-title/edit/index.js @@ -23,7 +23,7 @@ import LevelToolbar from './level-toolbar'; export default function SiteTitleEdit( { attributes, setAttributes } ) { const { level, textAlign } = attributes; const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' ); - const tagName = 0 === level ? 'p' : `h${ level }`; + const tagName = level === 0 ? 'p' : `h${ level }`; return ( <>