Skip to content

Commit

Permalink
Refine application of borders and display in editor
Browse files Browse the repository at this point in the history
This still isn't perfect. The cover content/background appears to be "under" dashed/dotted borders in the editor but are instead contained within them on the frontend.
  • Loading branch information
aaronrobertshaw committed Apr 29, 2022
1 parent 9f987f2 commit 783bcff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 15 additions & 2 deletions packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
isContentPositionCenter,
getPositionClassName,
} from './shared';
import cleanEmptyObject from '../utils/clean-empty-object';

extend( [ namesPlugin ] );

Expand Down Expand Up @@ -653,6 +654,13 @@ function CoverEdit( {
const ref = useRef();
const blockProps = useBlockProps( { ref } );
const borderProps = useBorderProps( attributes );
const borderRadiusStyles = cleanEmptyObject( {
borderTopLeftRadius: borderProps.style.borderTopLeftRadius,
borderTopRightRadius: borderProps.style.borderTopRightRadius,
borderBottomLeftRadius: borderProps.style.borderBottomLeftRadius,
borderBottomRightRadius: borderProps.style.borderBottomRightRadius,
borderRadius: borderProps.style.borderRadius,
} );

// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.
const hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;
Expand Down Expand Up @@ -757,6 +765,11 @@ function CoverEdit( {
} }
showHandle={ isSelected }
/>
<span
aria-hidden="true"
className={ 'block-library-cover__border-visualizer' }
style={ borderProps.style }
/>
<span
aria-hidden="true"
className={ classnames(
Expand Down Expand Up @@ -788,7 +801,7 @@ function CoverEdit( {
className="wp-block-cover__image-background"
alt={ alt }
src={ url }
style={ mediaStyle }
style={ { ...mediaStyle, ...borderRadiusStyles } }
/>
) }
{ url && isVideoBackground && (
Expand All @@ -799,7 +812,7 @@ function CoverEdit( {
muted
loop
src={ url }
style={ mediaStyle }
style={ { ...mediaStyle, ...borderRadiusStyles } }
/>
) }
{ isUploadingMedia && <Spinner /> }
Expand Down
7 changes: 6 additions & 1 deletion packages/block-library/src/cover/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
margin-left: auto;
}

.block-library-cover__resize-container {
.block-library-cover__resize-container,
.block-library-cover__border-visualizer {
position: absolute !important;
top: 0;
left: 0;
Expand All @@ -84,6 +85,10 @@
min-height: 50px;
}

.block-library-cover__border-visualizer {
z-index: z-index(".wp-block-cover.has-background-dim::before");
}

.block-library-cover__resize-container:not(.is-resizing) {
// Important is used to have higher specificity than the inline style set by re-resizable library.
height: auto !important;
Expand Down

0 comments on commit 783bcff

Please sign in to comment.