Skip to content

Commit

Permalink
Cover block: improve overlay opacity handling (#26133)
Browse files Browse the repository at this point in the history
* hide overlay opacity control if there is no overlay color or gradient

* remove default black background color of has-background-dim class

* combine selectors for overlay opacity

* make overlay opacity range step congruent with available styles
  • Loading branch information
stokesman authored Oct 19, 2020
1 parent 91514a5 commit c5ea5a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function CoverEdit( {
}
}

const canDim = !! url && ( overlayColor.color || gradientValue );
const hasBackground = !! ( url || overlayColor.color || gradientValue );
const showFocalPointPicker =
isVideoBackground ||
Expand Down Expand Up @@ -425,7 +426,7 @@ function CoverEdit( {
},
] }
>
{ !! url && (
{ canDim && (
<RangeControl
label={ __( 'Opacity' ) }
value={ dimRatio }
Expand All @@ -436,6 +437,7 @@ function CoverEdit( {
}
min={ 0 }
max={ 100 }
step={ 10 }
required
/>
) }
Expand Down
14 changes: 4 additions & 10 deletions packages/block-library/src/cover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
background-size: auto;
}

&.has-background-dim {
background-color: $black;

&::before {
content: "";
background-color: inherit;
}
&.has-background-dim::before {
content: "";
background-color: inherit;
}

&.has-background-dim:not(.has-background-gradient)::before,
Expand All @@ -57,9 +53,7 @@

@for $i from 1 through 10 {
&.has-background-dim.has-background-dim-#{ $i * 10 } {
&:not(.has-background-gradient)::before {
opacity: $i * 0.1;
}
&:not(.has-background-gradient)::before,
.wp-block-cover__gradient-background {
opacity: $i * 0.1;
}
Expand Down

0 comments on commit c5ea5a5

Please sign in to comment.