Skip to content

Commit 3256667

Browse files
A little refactoring
1 parent d38dacc commit 3256667

File tree

2 files changed

+26
-43
lines changed

2 files changed

+26
-43
lines changed

packages/base-styles/_z-index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $z-layers: (
3838
".edit-widgets-header": 30,
3939
".block-library-button__inline-link .block-editor-url-input__suggestions": 6, // URL suggestions for button block above sibling inserter
4040
".wp-block-cover__inner-container": 32, // InnerBlocks area inside cover image block. Must be higher than block popover and less than drop zone.
41-
".wp-block-cover.is-placeholder .components-placeholder.is-large": 1, // Cover block resizer component inside a large placeholder.
41+
".wp-block-cover.is-placeholder .components-placeholder.is-large": 32, // Cover block resizer component inside a large placeholder.
4242
".wp-block-cover.has-background-dim::before": 1, // Overlay area inside block cover need to be higher than the video background.
4343
".block-library-cover__padding-visualizer": 2, // BoxControl visualizer needs to be +1 higher than .wp-block-cover.has-background-dim::before
4444
".wp-block-cover__image-background": 0, // Image background inside cover block.

packages/block-library/src/cover/edit/index.js

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,27 @@ function CoverEdit( {
220220
overlayColor,
221221
};
222222

223+
const resizableCoverProps = {
224+
className: 'block-library-cover__resize-container',
225+
clientId,
226+
height,
227+
minHeight: parseFloat( minHeight ),
228+
onResizeStart: () => {
229+
setAttributes( { minHeightUnit: 'px' } );
230+
toggleSelection( false );
231+
},
232+
onResize: ( value ) => {
233+
setAttributes( { minHeight: value } );
234+
},
235+
onResizeStop: ( newMinHeight ) => {
236+
toggleSelection( true );
237+
setAttributes( { minHeight: newMinHeight } );
238+
},
239+
showHandle: true,
240+
size: resizableBoxDimensions,
241+
width,
242+
};
243+
223244
if ( ! hasInnerBlocks && ! hasBackground ) {
224245
return (
225246
<>
@@ -238,26 +259,7 @@ function CoverEdit( {
238259
currentSettings={ currentSettings }
239260
/>
240261
{ isSelected && (
241-
<ResizableCoverPopover
242-
clientId={ clientId }
243-
className="block-library-cover__resize-container is-placeholder"
244-
minHeight={ parseFloat( minHeight ) }
245-
onResizeStart={ () => {
246-
setAttributes( { minHeightUnit: 'px' } );
247-
toggleSelection( false );
248-
} }
249-
onResize={ ( value ) => {
250-
setAttributes( { minHeight: value } );
251-
} }
252-
onResizeStop={ ( newMinHeight ) => {
253-
toggleSelection( true );
254-
setAttributes( { minHeight: newMinHeight } );
255-
} }
256-
showHandle={ true }
257-
size={ { height: 'auto', width: 'auto' } }
258-
width={ width }
259-
height={ height }
260-
/>
262+
<ResizableCoverPopover { ...resizableCoverProps } />
261263
) }
262264
<div
263265
{ ...blockProps }
@@ -319,28 +321,6 @@ function CoverEdit( {
319321
coverRef={ ref }
320322
currentSettings={ currentSettings }
321323
/>
322-
{ isSelected && (
323-
<ResizableCoverPopover
324-
clientId={ clientId }
325-
className="block-library-cover__resize-container"
326-
minHeight={ parseFloat( minHeight ) }
327-
onResizeStart={ () => {
328-
setAttributes( { minHeightUnit: 'px' } );
329-
toggleSelection( false );
330-
} }
331-
onResize={ ( value ) => {
332-
setAttributes( { minHeight: value } );
333-
} }
334-
onResizeStop={ ( newMinHeight ) => {
335-
toggleSelection( true );
336-
setAttributes( { minHeight: newMinHeight } );
337-
} }
338-
showHandle
339-
size={ resizableBoxDimensions }
340-
width={ width }
341-
height={ height }
342-
/>
343-
) }
344324
<div
345325
{ ...blockProps }
346326
className={ classnames( classes, blockProps.className ) }
@@ -396,6 +376,9 @@ function CoverEdit( {
396376
/>
397377
<div { ...innerBlocksProps } />
398378
</div>
379+
{ isSelected && (
380+
<ResizableCoverPopover { ...resizableCoverProps } />
381+
) }
399382
</>
400383
);
401384
}

0 commit comments

Comments
 (0)