@@ -13,6 +13,7 @@ import { addFilter } from '@wordpress/hooks';
1313import { hasBlockSupport } from '@wordpress/blocks' ;
1414import { useSelect } from '@wordpress/data' ;
1515import {
16+ Button ,
1617 ToggleControl ,
1718 PanelBody ,
1819 __experimentalUnitControl as UnitControl ,
@@ -82,52 +83,72 @@ function LayoutPanel( { setAttributes, attributes } ) {
8283 />
8384 ) }
8485 { ! inherit && (
85- < div className = "block-editor-hooks__layout-controls" >
86- < div className = "block-editor-hooks__layout-controls-unit" >
87- < UnitControl
88- label = { __ ( 'Content' ) }
89- labelPosition = "top"
90- __unstableInputWidth = "80px"
91- value = { contentSize || wideSize || '' }
92- onChange = { ( nextWidth ) => {
93- nextWidth =
94- 0 > parseFloat ( nextWidth )
95- ? '0'
96- : nextWidth ;
97- setAttributes ( {
98- layout : {
99- ...layout ,
100- contentSize : nextWidth ,
101- } ,
102- } ) ;
103- } }
104- units = { CSS_UNITS }
105- />
106- < Icon icon = { positionCenter } />
86+ < >
87+ < div className = "block-editor-hooks__layout-controls" >
88+ < div className = "block-editor-hooks__layout-controls-unit" >
89+ < UnitControl
90+ label = { __ ( 'Content' ) }
91+ labelPosition = "top"
92+ __unstableInputWidth = "80px"
93+ value = { contentSize || wideSize || '' }
94+ onChange = { ( nextWidth ) => {
95+ nextWidth =
96+ 0 > parseFloat ( nextWidth )
97+ ? '0'
98+ : nextWidth ;
99+ setAttributes ( {
100+ layout : {
101+ ...layout ,
102+ contentSize : nextWidth ,
103+ } ,
104+ } ) ;
105+ } }
106+ units = { CSS_UNITS }
107+ />
108+ < Icon icon = { positionCenter } />
109+ </ div >
110+ < div className = "block-editor-hooks__layout-controls-unit" >
111+ < UnitControl
112+ label = { __ ( 'Wide' ) }
113+ labelPosition = "top"
114+ __unstableInputWidth = "80px"
115+ value = { wideSize || contentSize || '' }
116+ onChange = { ( nextWidth ) => {
117+ nextWidth =
118+ 0 > parseFloat ( nextWidth )
119+ ? '0'
120+ : nextWidth ;
121+ setAttributes ( {
122+ layout : {
123+ ...layout ,
124+ wideSize : nextWidth ,
125+ } ,
126+ } ) ;
127+ } }
128+ units = { CSS_UNITS }
129+ />
130+ < Icon icon = { stretchWide } />
131+ </ div >
107132 </ div >
108- < div className = "block-editor-hooks__layout-controls-unit" >
109- < UnitControl
110- label = { __ ( 'Wide' ) }
111- labelPosition = "top"
112- __unstableInputWidth = "80px"
113- value = { wideSize || contentSize || '' }
114- onChange = { ( nextWidth ) => {
115- nextWidth =
116- 0 > parseFloat ( nextWidth )
117- ? '0'
118- : nextWidth ;
133+ < div className = "block-editor-hooks__layout-controls-reset" >
134+ < Button
135+ isSecondary
136+ isSmall
137+ disabled = { ! contentSize && ! wideSize }
138+ onClick = { ( ) =>
119139 setAttributes ( {
120140 layout : {
121- ...layout ,
122- wideSize : nextWidth ,
141+ contentSize : undefined ,
142+ wideSize : undefined ,
143+ inherit : false ,
123144 } ,
124- } ) ;
125- } }
126- units = { CSS_UNITS }
127- />
128- < Icon icon = { stretchWide } / >
145+ } )
146+ }
147+ >
148+ { __ ( 'Reset' ) }
149+ </ Button >
129150 </ div >
130- </ div >
151+ </ >
131152 ) }
132153 < p className = "block-editor-hooks__layout-controls-helptext" >
133154 { __ (
0 commit comments