From d3d703b7e46f92d666397dd39ab0703e5c1a959e Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 14 Apr 2021 13:33:38 +0400 Subject: [PATCH] Add reset button to Layout controls --- packages/block-editor/src/hooks/layout.js | 103 ++++++++++++-------- packages/block-editor/src/hooks/layout.scss | 8 +- 2 files changed, 69 insertions(+), 42 deletions(-) diff --git a/packages/block-editor/src/hooks/layout.js b/packages/block-editor/src/hooks/layout.js index 4a4a6ee7ffd240..fc8feb56e8875c 100644 --- a/packages/block-editor/src/hooks/layout.js +++ b/packages/block-editor/src/hooks/layout.js @@ -13,6 +13,7 @@ import { addFilter } from '@wordpress/hooks'; import { hasBlockSupport } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { + Button, ToggleControl, PanelBody, __experimentalUnitControl as UnitControl, @@ -82,52 +83,72 @@ function LayoutPanel( { setAttributes, attributes } ) { /> ) } { ! inherit && ( -
-
- { - nextWidth = - 0 > parseFloat( nextWidth ) - ? '0' - : nextWidth; - setAttributes( { - layout: { - ...layout, - contentSize: nextWidth, - }, - } ); - } } - units={ CSS_UNITS } - /> - + <> +
+
+ { + nextWidth = + 0 > parseFloat( nextWidth ) + ? '0' + : nextWidth; + setAttributes( { + layout: { + ...layout, + contentSize: nextWidth, + }, + } ); + } } + units={ CSS_UNITS } + /> + +
+
+ { + nextWidth = + 0 > parseFloat( nextWidth ) + ? '0' + : nextWidth; + setAttributes( { + layout: { + ...layout, + wideSize: nextWidth, + }, + } ); + } } + units={ CSS_UNITS } + /> + +
-
- { - nextWidth = - 0 > parseFloat( nextWidth ) - ? '0' - : nextWidth; +
+
-
+ ) }

{ __( diff --git a/packages/block-editor/src/hooks/layout.scss b/packages/block-editor/src/hooks/layout.scss index 1c4773a8889ecf..3b06bc44478bad 100644 --- a/packages/block-editor/src/hooks/layout.scss +++ b/packages/block-editor/src/hooks/layout.scss @@ -1,6 +1,6 @@ .block-editor-hooks__layout-controls { display: flex; - margin-bottom: $grid-unit-30; + margin-bottom: $grid-unit-20; .block-editor-hooks__layout-controls-unit { display: flex; @@ -12,6 +12,12 @@ } } +.block-editor-hooks__layout-controls-reset { + display: flex; + justify-content: flex-end; + margin-bottom: $grid-unit-30; +} + .block-editor-hooks__layout-controls-helptext { font-size: $helptext-font-size; }