From 3f4d5220c2fbf7450621044cfc45f1516133fa6a Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Tue, 11 Feb 2020 09:39:26 +0600 Subject: [PATCH 01/23] Added a vertical style to the Buttons block --- packages/block-library/src/buttons/editor.scss | 12 +++++++++--- packages/block-library/src/buttons/style.scss | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index 2a07114b65ad50..5554dbd92de0c2 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -1,6 +1,12 @@ -.wp-block-buttons .wp-block.block-editor-block-list__block[data-type="core/button"] { - display: inline-block; - width: auto; +.wp-block-buttons { + .wp-block.block-editor-block-list__block[data-type="core/button"] { + display: inline-block; + width: auto; + } + + &.is-style-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { + display: block; + } } .wp-block[data-align="center"] > .wp-block-buttons { diff --git a/packages/block-library/src/buttons/style.scss b/packages/block-library/src/buttons/style.scss index fa869b97904b5c..2b7a3f3c13ce4c 100644 --- a/packages/block-library/src/buttons/style.scss +++ b/packages/block-library/src/buttons/style.scss @@ -13,3 +13,7 @@ .wp-block-buttons.aligncenter { text-align: center; } + +.wp-block-buttons.is-style-vertical .wp-block-button { + display: block; +} From 056091136814d3275665826e2419180bd588c283 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 11:45:49 +0600 Subject: [PATCH 02/23] Reverted the styles approach --- packages/block-library/src/buttons/editor.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index 5554dbd92de0c2..f493f704a58a7d 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -3,10 +3,6 @@ display: inline-block; width: auto; } - - &.is-style-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { - display: block; - } } .wp-block[data-align="center"] > .wp-block-buttons { From 8c4fd9b47ebd46cc45ff1948cb9eb6c4d9bd5ee6 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 11:48:41 +0600 Subject: [PATCH 03/23] Attempted the solution with attributes and a RadioControl --- packages/block-library/src/buttons/block.json | 6 ++++ packages/block-library/src/buttons/edit.js | 35 +++++++++++++++++-- .../block-library/src/buttons/editor.scss | 5 +++ packages/block-library/src/buttons/save.js | 5 +-- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/buttons/block.json b/packages/block-library/src/buttons/block.json index 93c7eea7015a16..ff801e852ac9c8 100644 --- a/packages/block-library/src/buttons/block.json +++ b/packages/block-library/src/buttons/block.json @@ -5,5 +5,11 @@ "align": true, "alignWide": false, "lightBlockWrapper": true + }, + "attributes": { + "blockDirection": { + "type": "string", + "default": "horizontal" + } } } diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index f6aa94582b3a6c..0e1ca12161f916 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -1,11 +1,14 @@ /** * WordPress dependencies */ +import { __ } from '@wordpress/i18n'; import { __experimentalAlignmentHookSettingsProvider as AlignmentHookSettingsProvider, InnerBlocks, __experimentalBlock as Block, + InspectorControls, } from '@wordpress/block-editor'; +import { PanelBody, RadioControl } from '@wordpress/components'; /** * Internal dependencies @@ -20,16 +23,42 @@ const alignmentHooksSetting = { isEmbedButton: true, }; -function ButtonsEdit() { +function ButtonsEdit( { attributes, setAttributes } ) { + const { blockDirection } = attributes; + return ( - + + + + + setAttributes( { + blockDirection: value, + } ) + } + /> + + ); } diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index f493f704a58a7d..e1512589c5796c 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -3,6 +3,11 @@ display: inline-block; width: auto; } + + &.is-direction-vertical + .wp-block.block-editor-block-list__block[data-type="core/button"] { + display: block; + } } .wp-block[data-align="center"] > .wp-block-buttons { diff --git a/packages/block-library/src/buttons/save.js b/packages/block-library/src/buttons/save.js index 91cb804231d058..66ad4452d76fd0 100644 --- a/packages/block-library/src/buttons/save.js +++ b/packages/block-library/src/buttons/save.js @@ -3,9 +3,10 @@ */ import { InnerBlocks } from '@wordpress/block-editor'; -export default function save() { +export default function save( { attributes } ) { + const { blockDirection } = attributes; return ( -
+
); From 825693e40b2209f0d235577a96a068a014d5c807 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 12:58:00 +0600 Subject: [PATCH 04/23] Updated tests --- .../e2e-tests/fixtures/blocks/core__buttons.html | 4 ++-- .../e2e-tests/fixtures/blocks/core__buttons.json | 8 +++++--- .../fixtures/blocks/core__buttons.parsed.json | 15 +++------------ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.html b/packages/e2e-tests/fixtures/blocks/core__buttons.html index e70af7acc72ad4..130051d110e075 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.html @@ -1,5 +1,5 @@ -
+
@@ -8,4 +8,4 @@
- + \ No newline at end of file diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.json b/packages/e2e-tests/fixtures/blocks/core__buttons.json index 044daeb82101ac..f99d9e11c795e2 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.json @@ -3,7 +3,9 @@ "clientId": "_clientId_0", "name": "core/buttons", "isValid": true, - "attributes": {}, + "attributes": { + "blockDirection": "horizontal" + }, "innerBlocks": [ { "clientId": "_clientId_0", @@ -26,6 +28,6 @@ "originalContent": "" } ], - "originalContent": "
\n\t\n\n\t\n
" + "originalContent": "
\n\t\n\n\t\n
" } -] +] \ No newline at end of file diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json index b96b1f50db1fc9..51476ccabe398e 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json @@ -22,22 +22,13 @@ ] } ], - "innerHTML": "\n
\n\t\n\n\t\n
\n", + "innerHTML": "\n
\n\t\n\n\t\n
\n", "innerContent": [ - "\n
\n\t", + "\n
\n\t", null, "\n\n\t", null, "\n
\n" ] - }, - { - "blockName": null, - "attrs": {}, - "innerBlocks": [], - "innerHTML": "\n", - "innerContent": [ - "\n" - ] } -] +] \ No newline at end of file From 13c99c950b02271109e71424a3160871ae5de00a Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 16:11:08 +0600 Subject: [PATCH 05/23] Added deprecation --- .../block-library/src/buttons/deprecated.js | 29 +++++++++++++++++++ packages/block-library/src/buttons/index.js | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 packages/block-library/src/buttons/deprecated.js diff --git a/packages/block-library/src/buttons/deprecated.js b/packages/block-library/src/buttons/deprecated.js new file mode 100644 index 00000000000000..6340cfa2f2d094 --- /dev/null +++ b/packages/block-library/src/buttons/deprecated.js @@ -0,0 +1,29 @@ +/** + * WordPress dependencies + */ +import { InnerBlocks } from '@wordpress/block-editor'; + +const deprecated = [ + { + attributes: { + blockDirection: { + type: 'string', + default: 'horizontal', + }, + }, + migrate() { + return { + blockDirection: 'horizontal', + }; + }, + save() { + return ( +
+ +
+ ); + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/buttons/index.js b/packages/block-library/src/buttons/index.js index 68f51a5a476b99..d08452049920a7 100644 --- a/packages/block-library/src/buttons/index.js +++ b/packages/block-library/src/buttons/index.js @@ -7,6 +7,7 @@ import { button as icon } from '@wordpress/icons'; /** * Internal dependencies */ +import deprecated from './deprecated'; import transforms from './transforms'; import edit from './edit'; import metadata from './block.json'; @@ -26,4 +27,5 @@ export const settings = { transforms, edit, save, + deprecated, }; From de8adae7098ec67dca112d2f9dae4662894405f2 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 17:13:25 +0600 Subject: [PATCH 06/23] Added missing newline at end of files --- packages/e2e-tests/fixtures/blocks/core__buttons.html | 2 +- packages/e2e-tests/fixtures/blocks/core__buttons.json | 2 +- packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.html b/packages/e2e-tests/fixtures/blocks/core__buttons.html index 130051d110e075..c2bc89e109f308 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.html @@ -8,4 +8,4 @@
- \ No newline at end of file + diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.json b/packages/e2e-tests/fixtures/blocks/core__buttons.json index f99d9e11c795e2..dd0ea5dda9872b 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.json @@ -30,4 +30,4 @@ ], "originalContent": "
\n\t\n\n\t\n
" } -] \ No newline at end of file +] diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json index 51476ccabe398e..2d7f5febf384c4 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json @@ -31,4 +31,4 @@ "\n
\n" ] } -] \ No newline at end of file +] From 6cce01cbbb5befb05dbb75904750a6f1bd8489c4 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sun, 5 Apr 2020 17:37:55 +0600 Subject: [PATCH 07/23] Fixed failed integration error --- .../e2e-tests/fixtures/blocks/core__buttons.parsed.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json index 2d7f5febf384c4..049b5f75cf06b9 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json @@ -30,5 +30,14 @@ null, "\n
\n" ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] } ] From cedeacc2f635c4bb1df590b9ace601c7fc925649 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 10 Apr 2020 22:02:01 +0600 Subject: [PATCH 08/23] Fixed misspelled class --- packages/block-library/src/buttons/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/buttons/style.scss b/packages/block-library/src/buttons/style.scss index 2b7a3f3c13ce4c..959aa7c052a2dd 100644 --- a/packages/block-library/src/buttons/style.scss +++ b/packages/block-library/src/buttons/style.scss @@ -14,6 +14,6 @@ text-align: center; } -.wp-block-buttons.is-style-vertical .wp-block-button { +.wp-block-buttons.is-direction-vertical .wp-block-button { display: block; } From 97b907919f6d5e317cead0321722b27d1e07e2b2 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 11 Apr 2020 06:30:52 +0600 Subject: [PATCH 09/23] Add the 'is-direction-vertical' class only when there's a vertical direction defined --- packages/block-library/src/buttons/save.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/buttons/save.js b/packages/block-library/src/buttons/save.js index 66ad4452d76fd0..c69dcf2d81e6ab 100644 --- a/packages/block-library/src/buttons/save.js +++ b/packages/block-library/src/buttons/save.js @@ -6,7 +6,11 @@ import { InnerBlocks } from '@wordpress/block-editor'; export default function save( { attributes } ) { const { blockDirection } = attributes; return ( -
+
); From bc1c4c67b965e4c684299e3af6415492ec6279ab Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 11 Apr 2020 07:05:45 +0600 Subject: [PATCH 10/23] Updated styles --- .../block-library/src/buttons/editor.scss | 22 +++++++++++-------- packages/block-library/src/buttons/style.scss | 6 +++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index e1512589c5796c..de530aff3e056f 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -1,13 +1,17 @@ -.wp-block-buttons { - .wp-block.block-editor-block-list__block[data-type="core/button"] { - display: inline-block; - width: auto; - } +.wp-block-buttons .wp-block.block-editor-block-list__block[data-type="core/button"] { + display: inline-block; + width: auto; +} + +.wp-block-buttons.is-direction-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { + display: block; + width: max-content; + margin-left: 0; +} - &.is-direction-vertical - .wp-block.block-editor-block-list__block[data-type="core/button"] { - display: block; - } +.block-editor-block-list__block[data-type="core/buttons"][data-align="center"] .wp-block-buttons.is-direction-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { + margin-left: auto; + margin-right: auto; } .wp-block[data-align="center"] > .wp-block-buttons { diff --git a/packages/block-library/src/buttons/style.scss b/packages/block-library/src/buttons/style.scss index 959aa7c052a2dd..d541aa206b9d65 100644 --- a/packages/block-library/src/buttons/style.scss +++ b/packages/block-library/src/buttons/style.scss @@ -16,4 +16,10 @@ .wp-block-buttons.is-direction-vertical .wp-block-button { display: block; + width: max-content; +} + +.wp-block-buttons.aligncenter.is-direction-vertical .wp-block-button { + margin-left: auto; + margin-right: auto; } From 2e9ca53e4a312a4163c639e939b8af28ccafa6be Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 11 Apr 2020 07:10:34 +0600 Subject: [PATCH 11/23] Remove deprecation as we're not changing the markup by default --- .../block-library/src/buttons/deprecated.js | 29 ------------------- packages/block-library/src/buttons/index.js | 2 -- 2 files changed, 31 deletions(-) delete mode 100644 packages/block-library/src/buttons/deprecated.js diff --git a/packages/block-library/src/buttons/deprecated.js b/packages/block-library/src/buttons/deprecated.js deleted file mode 100644 index 6340cfa2f2d094..00000000000000 --- a/packages/block-library/src/buttons/deprecated.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * WordPress dependencies - */ -import { InnerBlocks } from '@wordpress/block-editor'; - -const deprecated = [ - { - attributes: { - blockDirection: { - type: 'string', - default: 'horizontal', - }, - }, - migrate() { - return { - blockDirection: 'horizontal', - }; - }, - save() { - return ( -
- -
- ); - }, - }, -]; - -export default deprecated; diff --git a/packages/block-library/src/buttons/index.js b/packages/block-library/src/buttons/index.js index d08452049920a7..68f51a5a476b99 100644 --- a/packages/block-library/src/buttons/index.js +++ b/packages/block-library/src/buttons/index.js @@ -7,7 +7,6 @@ import { button as icon } from '@wordpress/icons'; /** * Internal dependencies */ -import deprecated from './deprecated'; import transforms from './transforms'; import edit from './edit'; import metadata from './block.json'; @@ -27,5 +26,4 @@ export const settings = { transforms, edit, save, - deprecated, }; From 97cc42bf6992b2ba058b8a3e4d3698b8c8c576a2 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 11 Apr 2020 08:01:19 +0600 Subject: [PATCH 12/23] Re-wrote tests --- .../fixtures/blocks/core__buttons.html | 2 +- .../fixtures/blocks/core__buttons.json | 2 +- .../fixtures/blocks/core__buttons.parsed.json | 4 +- .../blocks/core__buttons__vertical.html | 11 +++++ .../blocks/core__buttons__vertical.json | 34 +++++++++++++++ .../core__buttons__vertical.parsed.json | 43 +++++++++++++++++++ .../core__buttons__vertical.serialized.html | 10 +++++ 7 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.html b/packages/e2e-tests/fixtures/blocks/core__buttons.html index c2bc89e109f308..e70af7acc72ad4 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.html @@ -1,5 +1,5 @@ -
+
diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.json b/packages/e2e-tests/fixtures/blocks/core__buttons.json index dd0ea5dda9872b..9b567b977d6132 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.json @@ -28,6 +28,6 @@ "originalContent": "" } ], - "originalContent": "
\n\t\n\n\t\n
" + "originalContent": "
\n\t\n\n\t\n
" } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json index 049b5f75cf06b9..b96b1f50db1fc9 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json @@ -22,9 +22,9 @@ ] } ], - "innerHTML": "\n
\n\t\n\n\t\n
\n", + "innerHTML": "\n
\n\t\n\n\t\n
\n", "innerContent": [ - "\n
\n\t", + "\n
\n\t", null, "\n\n\t", null, diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html new file mode 100644 index 00000000000000..ef5c38227cd610 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html @@ -0,0 +1,11 @@ + +
+ + My button 1 + + + + My button 2 + +
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json new file mode 100644 index 00000000000000..c18939601f57fe --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json @@ -0,0 +1,34 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/buttons", + "isValid": true, + "attributes": { + "blockDirection": "vertical", + "className": "is-direction-vertical" + }, + "innerBlocks": [ + { + "clientId": "_clientId_0", + "name": "core/button", + "isValid": true, + "attributes": { + "text": "My button 1" + }, + "innerBlocks": [], + "originalContent": "My button 1" + }, + { + "clientId": "_clientId_1", + "name": "core/button", + "isValid": true, + "attributes": { + "text": "My button 2" + }, + "innerBlocks": [], + "originalContent": "My button 2" + } + ], + "originalContent": "
\n\t\n\n\t\n
" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json new file mode 100644 index 00000000000000..c45572d9fa9c9a --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json @@ -0,0 +1,43 @@ +[ + { + "blockName": "core/buttons", + "attrs": {}, + "innerBlocks": [ + { + "blockName": "core/button", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\tMy button 1\n\t", + "innerContent": [ + "\n\tMy button 1\n\t" + ] + }, + { + "blockName": "core/button", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\tMy button 2\n\t", + "innerContent": [ + "\n\tMy button 2\n\t" + ] + } + ], + "innerHTML": "\n
\n\t\n\n\t\n
\n", + "innerContent": [ + "\n
\n\t", + null, + "\n\n\t", + null, + "\n
\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html new file mode 100644 index 00000000000000..9f318eb295c819 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -0,0 +1,10 @@ + +
+ My button 1 + + + + My button 2 +
+ + \ No newline at end of file From 06e4d1b0d83f1796154d79c26a4d4c4b7bca6385 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 11 Apr 2020 08:07:57 +0600 Subject: [PATCH 13/23] Fixed formatting --- .../core__buttons__vertical.serialized.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html index 9f318eb295c819..b81014663c3b24 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -1,10 +1,9 @@
- My button 1 - - - - My button 2 -
- - \ No newline at end of file +My button 1 + + + +My button 2 +
+ From f1002cd02e5b0a991cb4edaeda469088955ba6da Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 25 Apr 2020 21:01:35 +0600 Subject: [PATCH 14/23] Updated tests --- packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json | 2 +- .../fixtures/blocks/core__buttons__vertical.serialized.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json index c18939601f57fe..92e11e26f1bcf0 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json @@ -4,7 +4,7 @@ "name": "core/buttons", "isValid": true, "attributes": { - "blockDirection": "vertical", + "blockDirection": "horizontal", "className": "is-direction-vertical" }, "innerBlocks": [ diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html index b81014663c3b24..f584b5bf21ea2a 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -1,4 +1,4 @@ - +
My button 1 From 46ead0c1ddc33a8a05e6eb3f0808a2d68ff21a6e Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 15 May 2020 22:35:10 +0600 Subject: [PATCH 15/23] Renamed attribute 'blockDirection' to 'orientation' --- packages/block-library/src/buttons/block.json | 2 +- packages/block-library/src/buttons/edit.js | 10 +++++----- packages/block-library/src/buttons/save.js | 4 ++-- packages/e2e-tests/fixtures/blocks/core__buttons.json | 2 +- .../fixtures/blocks/core__buttons__vertical.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/buttons/block.json b/packages/block-library/src/buttons/block.json index ff801e852ac9c8..b0b4762231c810 100644 --- a/packages/block-library/src/buttons/block.json +++ b/packages/block-library/src/buttons/block.json @@ -7,7 +7,7 @@ "lightBlockWrapper": true }, "attributes": { - "blockDirection": { + "orientation": { "type": "string", "default": "horizontal" } diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index 0e1ca12161f916..e563b6bffcb0d6 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -24,26 +24,26 @@ const alignmentHooksSetting = { }; function ButtonsEdit( { attributes, setAttributes } ) { - const { blockDirection } = attributes; + const { orientation } = attributes; return ( setAttributes( { - blockDirection: value, + orientation: value, } ) } /> diff --git a/packages/block-library/src/buttons/save.js b/packages/block-library/src/buttons/save.js index c69dcf2d81e6ab..41d4b6686825a8 100644 --- a/packages/block-library/src/buttons/save.js +++ b/packages/block-library/src/buttons/save.js @@ -4,11 +4,11 @@ import { InnerBlocks } from '@wordpress/block-editor'; export default function save( { attributes } ) { - const { blockDirection } = attributes; + const { orientation } = attributes; return (
diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.json b/packages/e2e-tests/fixtures/blocks/core__buttons.json index 9b567b977d6132..31f63db0e97fce 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.json @@ -4,7 +4,7 @@ "name": "core/buttons", "isValid": true, "attributes": { - "blockDirection": "horizontal" + "orientation": "horizontal" }, "innerBlocks": [ { diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json index 92e11e26f1bcf0..e1a65476741410 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json @@ -4,7 +4,7 @@ "name": "core/buttons", "isValid": true, "attributes": { - "blockDirection": "horizontal", + "orientation": "horizontal", "className": "is-direction-vertical" }, "innerBlocks": [ From 6a9ca40e560f04cb9e4ce6162eb137c0e1449955 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 15 May 2020 22:47:49 +0600 Subject: [PATCH 16/23] Used 'classnames' --- packages/block-library/src/buttons/edit.js | 11 ++++++++--- packages/block-library/src/buttons/save.js | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index e563b6bffcb0d6..e837bca164bb7b 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -28,9 +33,9 @@ function ButtonsEdit( { attributes, setAttributes } ) { return (
From 4e84c112ada3a07879b9d8d6e30c3ce5885a587e Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 15 May 2020 22:51:19 +0600 Subject: [PATCH 17/23] Renamed 'is-direction-vertical' to 'is-vertical' --- packages/block-library/src/buttons/editor.scss | 10 +++++++--- packages/block-library/src/buttons/style.scss | 4 ++-- .../fixtures/blocks/core__buttons__vertical.html | 2 +- .../fixtures/blocks/core__buttons__vertical.json | 4 ++-- .../blocks/core__buttons__vertical.parsed.json | 4 ++-- .../core__buttons__vertical.serialized.html | 16 +++++++++------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index de530aff3e056f..24b27ceee5c95f 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -1,15 +1,19 @@ -.wp-block-buttons .wp-block.block-editor-block-list__block[data-type="core/button"] { +.wp-block-buttons +.wp-block.block-editor-block-list__block[data-type="core/button"] { display: inline-block; width: auto; } -.wp-block-buttons.is-direction-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { +.wp-block-buttons.is-vertical +.wp-block.block-editor-block-list__block[data-type="core/button"] { display: block; width: max-content; margin-left: 0; } -.block-editor-block-list__block[data-type="core/buttons"][data-align="center"] .wp-block-buttons.is-direction-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { +.block-editor-block-list__block[data-type="core/buttons"][data-align="center"] +.wp-block-buttons.is-vertical +.wp-block.block-editor-block-list__block[data-type="core/button"] { margin-left: auto; margin-right: auto; } diff --git a/packages/block-library/src/buttons/style.scss b/packages/block-library/src/buttons/style.scss index d541aa206b9d65..232de1e33573aa 100644 --- a/packages/block-library/src/buttons/style.scss +++ b/packages/block-library/src/buttons/style.scss @@ -14,12 +14,12 @@ text-align: center; } -.wp-block-buttons.is-direction-vertical .wp-block-button { +.wp-block-buttons.is-vertical .wp-block-button { display: block; width: max-content; } -.wp-block-buttons.aligncenter.is-direction-vertical .wp-block-button { +.wp-block-buttons.aligncenter.is-vertical .wp-block-button { margin-left: auto; margin-right: auto; } diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html index ef5c38227cd610..5e292d72159ac0 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html @@ -1,5 +1,5 @@ -
+
My button 1 diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json index e1a65476741410..68904c3940b74e 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json @@ -5,7 +5,7 @@ "isValid": true, "attributes": { "orientation": "horizontal", - "className": "is-direction-vertical" + "className": "is-vertical" }, "innerBlocks": [ { @@ -29,6 +29,6 @@ "originalContent": "My button 2" } ], - "originalContent": "
\n\t\n\n\t\n
" + "originalContent": "
\n\t\n\n\t\n
" } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json index c45572d9fa9c9a..3a60ee41e11937 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json @@ -22,9 +22,9 @@ ] } ], - "innerHTML": "\n
\n\t\n\n\t\n
\n", + "innerHTML": "\n
\n\t\n\n\t\n
\n", "innerContent": [ - "\n
\n\t", + "\n
\n\t", null, "\n\n\t", null, diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html index f584b5bf21ea2a..85503daa7f0f13 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -1,9 +1,11 @@ - -
-My button 1 - + + + + My button 2 + +
From 811d87442ff4b2f7718e9e2084f36ad5a64a31ab Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 15 May 2020 23:11:23 +0600 Subject: [PATCH 18/23] Reformed styles according to review --- packages/block-library/src/buttons/editor.scss | 9 --------- packages/block-library/src/buttons/style.scss | 8 ++------ 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/block-library/src/buttons/editor.scss b/packages/block-library/src/buttons/editor.scss index 24b27ceee5c95f..87019cd02f5647 100644 --- a/packages/block-library/src/buttons/editor.scss +++ b/packages/block-library/src/buttons/editor.scss @@ -7,15 +7,6 @@ .wp-block-buttons.is-vertical .wp-block.block-editor-block-list__block[data-type="core/button"] { display: block; - width: max-content; - margin-left: 0; -} - -.block-editor-block-list__block[data-type="core/buttons"][data-align="center"] -.wp-block-buttons.is-vertical -.wp-block.block-editor-block-list__block[data-type="core/button"] { - margin-left: auto; - margin-right: auto; } .wp-block[data-align="center"] > .wp-block-buttons { diff --git a/packages/block-library/src/buttons/style.scss b/packages/block-library/src/buttons/style.scss index 232de1e33573aa..def0cdb84d2607 100644 --- a/packages/block-library/src/buttons/style.scss +++ b/packages/block-library/src/buttons/style.scss @@ -16,10 +16,6 @@ .wp-block-buttons.is-vertical .wp-block-button { display: block; - width: max-content; -} - -.wp-block-buttons.aligncenter.is-vertical .wp-block-button { - margin-left: auto; - margin-right: auto; + margin-left: 0; + margin-right: 0; } From 602c287181e1a0788fda1a539fd3dcedcd2ed2c1 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Fri, 15 May 2020 23:13:19 +0600 Subject: [PATCH 19/23] Renamed label 'direction' to 'orientation' --- packages/block-library/src/buttons/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index e837bca164bb7b..9e903d9bbe55a8 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -47,7 +47,7 @@ function ButtonsEdit( { attributes, setAttributes } ) { Date: Sat, 16 May 2020 00:08:01 +0600 Subject: [PATCH 20/23] Updated tests --- .../blocks/core__buttons__vertical.serialized.html | 14 ++++++-------- .../blocks/core_buttons__simple__deprecated.json | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html index 85503daa7f0f13..a0471cc32886b3 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -1,11 +1,9 @@ - diff --git a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json index d77d9752de37b0..7d376171c5d656 100644 --- a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json +++ b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json @@ -3,7 +3,9 @@ "clientId": "_clientId_0", "name": "core/buttons", "isValid": true, - "attributes": {}, + "attributes": { + "orientation": "horizontal" + }, "innerBlocks": [ { "clientId": "_clientId_0", From e635abfb7801c3b4d7b74be614298cd60d2bef31 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Wed, 27 May 2020 13:42:21 +0600 Subject: [PATCH 21/23] Updated the tests according to the new full-content test instructions --- .../e2e-tests/fixtures/blocks/core__buttons.html | 10 +++++++--- .../e2e-tests/fixtures/blocks/core__buttons.json | 4 ++-- .../fixtures/blocks/core__buttons.parsed.json | 12 +++++++----- .../fixtures/blocks/core__buttons__vertical.html | 10 +++++++--- .../fixtures/blocks/core__buttons__vertical.json | 7 +++---- .../blocks/core__buttons__vertical.parsed.json | 12 +++++++----- .../blocks/core__buttons__vertical.serialized.html | 2 +- .../blocks/core_buttons__simple__deprecated.html | 2 +- .../blocks/core_buttons__simple__deprecated.json | 4 ++-- .../core_buttons__simple__deprecated.parsed.json | 4 +++- 10 files changed, 40 insertions(+), 27 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.html b/packages/e2e-tests/fixtures/blocks/core__buttons.html index e70af7acc72ad4..21c9205b162d06 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.html @@ -1,11 +1,15 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.json b/packages/e2e-tests/fixtures/blocks/core__buttons.json index 31f63db0e97fce..72578cb04bbd9e 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.json @@ -15,7 +15,7 @@ "text": "My button 1" }, "innerBlocks": [], - "originalContent": "" + "originalContent": "
\n\t\tMy button 1\n\t
" }, { "clientId": "_clientId_1", @@ -25,7 +25,7 @@ "text": "My button 2" }, "innerBlocks": [], - "originalContent": "" + "originalContent": "
\n\t\tMy button 2\n\t
" } ], "originalContent": "
\n\t\n\n\t\n
" diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json index b96b1f50db1fc9..3ab0c2cd44743a 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json @@ -1,24 +1,26 @@ [ { "blockName": "core/buttons", - "attrs": {}, + "attrs": { + "orientation": "horizontal" + }, "innerBlocks": [ { "blockName": "core/button", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t\n\t", + "innerHTML": "\n\t
\n\t\tMy button 1\n\t
\n\t", "innerContent": [ - "\n\t\n\t" + "\n\t
\n\t\tMy button 1\n\t
\n\t" ] }, { "blockName": "core/button", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t\n\t", + "innerHTML": "\n\t
\n\t\tMy button 2\n\t
\n\t", "innerContent": [ - "\n\t\n\t" + "\n\t
\n\t\tMy button 2\n\t
\n\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html index 5e292d72159ac0..a520639ba8da5b 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.html @@ -1,11 +1,15 @@ - + diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json index 68904c3940b74e..885987c2cb11b5 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.json @@ -4,8 +4,7 @@ "name": "core/buttons", "isValid": true, "attributes": { - "orientation": "horizontal", - "className": "is-vertical" + "orientation": "vertical" }, "innerBlocks": [ { @@ -16,7 +15,7 @@ "text": "My button 1" }, "innerBlocks": [], - "originalContent": "My button 1" + "originalContent": "
\n\t\tMy button 1\n\t
" }, { "clientId": "_clientId_1", @@ -26,7 +25,7 @@ "text": "My button 2" }, "innerBlocks": [], - "originalContent": "My button 2" + "originalContent": "
\n\t\tMy button 2\n\t
" } ], "originalContent": "
\n\t\n\n\t\n
" diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json index 3a60ee41e11937..c070a3490e9cce 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.parsed.json @@ -1,24 +1,26 @@ [ { "blockName": "core/buttons", - "attrs": {}, + "attrs": { + "orientation": "vertical" + }, "innerBlocks": [ { "blockName": "core/button", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\tMy button 1\n\t", + "innerHTML": "\n\t
\n\t\tMy button 1\n\t
\n\t", "innerContent": [ - "\n\tMy button 1\n\t" + "\n\t
\n\t\tMy button 1\n\t
\n\t" ] }, { "blockName": "core/button", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\tMy button 2\n\t", + "innerHTML": "\n\t
\n\t\tMy button 2\n\t
\n\t", "innerContent": [ - "\n\tMy button 2\n\t" + "\n\t
\n\t\tMy button 2\n\t
\n\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html index a0471cc32886b3..079253c245973d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__buttons__vertical.serialized.html @@ -1,4 +1,4 @@ - +
diff --git a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.html b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.html index 02f5487560cee4..b86a635201f94f 100644 --- a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.html +++ b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.html @@ -1,4 +1,4 @@ - +
My button 1 diff --git a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json index 7d376171c5d656..1ae83f325b61d5 100644 --- a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json +++ b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.json @@ -4,8 +4,8 @@ "name": "core/buttons", "isValid": true, "attributes": { - "orientation": "horizontal" - }, + "orientation": "horizontal" + }, "innerBlocks": [ { "clientId": "_clientId_0", diff --git a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.parsed.json b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.parsed.json index ee9dd97313a48b..1f968a3e87e047 100644 --- a/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core_buttons__simple__deprecated.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/buttons", - "attrs": {}, + "attrs": { + "orientation": "horizontal" + }, "innerBlocks": [ { "blockName": "core/button", From 83b50ba114fa404167b190744773edc10cdf9bb3 Mon Sep 17 00:00:00 2001 From: nfmohit-wpmudev Date: Sat, 30 May 2020 20:55:57 +0600 Subject: [PATCH 22/23] Implemented suggested code quality changes --- packages/block-library/src/buttons/edit.js | 8 +++----- packages/block-library/src/buttons/editor.scss | 6 ++---- packages/block-library/src/buttons/save.js | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index 9e903d9bbe55a8..a4bcc36efe4f90 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -6,14 +6,14 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; import { __experimentalAlignmentHookSettingsProvider as AlignmentHookSettingsProvider, - InnerBlocks, __experimentalBlock as Block, + InnerBlocks, InspectorControls, } from '@wordpress/block-editor'; import { PanelBody, RadioControl } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -28,9 +28,7 @@ const alignmentHooksSetting = { isEmbedButton: true, }; -function ButtonsEdit( { attributes, setAttributes } ) { - const { orientation } = attributes; - +function ButtonsEdit( { attributes: { orientation }, setAttributes } ) { return ( Date: Tue, 9 Jun 2020 21:33:42 +0600 Subject: [PATCH 23/23] Extracted orientation options to a file-level constant named ORIENTATION_OPTIONS --- packages/block-library/src/buttons/edit.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/buttons/edit.js b/packages/block-library/src/buttons/edit.js index a4bcc36efe4f90..0ce58fd6a94283 100644 --- a/packages/block-library/src/buttons/edit.js +++ b/packages/block-library/src/buttons/edit.js @@ -22,6 +22,13 @@ import { name as buttonBlockName } from '../button/'; const ALLOWED_BLOCKS = [ buttonBlockName ]; const BUTTONS_TEMPLATE = [ [ 'core/button' ] ]; +const ORIENTATION_OPTIONS = [ + { label: __( 'Horizontal' ), value: 'horizontal' }, + { + label: __( 'Vertical' ), + value: 'vertical', + }, +]; // Inside buttons block alignment options are not supported. const alignmentHooksSetting = { @@ -47,13 +54,7 @@ function ButtonsEdit( { attributes: { orientation }, setAttributes } ) { setAttributes( { orientation: value,