Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: Fix per block text color customization for cover block #34188

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -639,6 +639,7 @@ function CoverEdit( {
'has-custom-content-position': ! isContentPositionCenter(
contentPosition
),
'is-default-background-color': ! overlayColor.class,
},
getPositionClassName( contentPosition )
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/cover/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 2 additions & 12 deletions packages/block-library/src/cover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -104,7 +95,6 @@
.wp-block-cover__inner-container {
width: 100%;
z-index: z-index(".wp-block-cover__inner-container");
color: $white;
}

p,
Expand Down