diff --git a/packages/block-library/src/cover/edit.js b/packages/block-library/src/cover/edit.js index 244390fd3a9ac..54833248a74d3 100644 --- a/packages/block-library/src/cover/edit.js +++ b/packages/block-library/src/cover/edit.js @@ -629,7 +629,7 @@ function CoverEdit( { dimRatioToClass( dimRatio ), { 'is-dark-theme': isDark, - 'has-background-dim': dimRatio !== 0, + 'has-background-dim': url && dimRatio !== 0, 'is-transient': isUploadingMedia, 'has-parallax': hasParallax, 'is-repeated': isRepeated, @@ -639,6 +639,7 @@ function CoverEdit( { 'has-custom-content-position': ! isContentPositionCenter( contentPosition ), + 'is-default-background-color': ! overlayColor.class, }, getPositionClassName( contentPosition ) ); diff --git a/packages/block-library/src/cover/save.js b/packages/block-library/src/cover/save.js index 1b1de52e07521..1ddd572d9df16 100644 --- a/packages/block-library/src/cover/save.js +++ b/packages/block-library/src/cover/save.js @@ -76,7 +76,7 @@ export default function save( { attributes } ) { dimRatioToClass( dimRatio ), overlayColorClass, { - 'has-background-dim': dimRatio !== 0, + 'has-background-dim': url && dimRatio !== 0, 'has-parallax': hasParallax, 'is-repeated': isRepeated, 'has-background-gradient': gradient || customGradient, diff --git a/packages/block-library/src/cover/style.scss b/packages/block-library/src/cover/style.scss index 43155f41d9ebf..bcdfbfcee5169 100644 --- a/packages/block-library/src/cover/style.scss +++ b/packages/block-library/src/cover/style.scss @@ -11,6 +11,7 @@ padding: 1em; // This block has customizable padding, border-box makes that more predictable. box-sizing: border-box; + color: $white; &.has-parallax { background-attachment: fixed; @@ -33,17 +34,7 @@ background-size: auto; } - /** - * Set a default background color for has-background-dim _unless_ it includes another - * background-color class (e.g. has-green-background-color). The presence of another - * background-color class implies that another style will provide the background color - * for the overlay. - * - * See: - * - Issue with background color specificity: https://github.com/WordPress/gutenberg/issues/26545 - * - Issue with alternative fix: https://github.com/WordPress/gutenberg/issues/26545 - */ - &.has-background-dim:not([class*="-background-color"]) { + &.is-default-background-color { background-color: $black; } @@ -104,7 +95,6 @@ .wp-block-cover__inner-container { width: 100%; z-index: z-index(".wp-block-cover__inner-container"); - color: $white; } p,