-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Cover block: Fix gradient overlay (remove black background color) #38765
Cover block: Fix gradient overlay (remove black background color) #38765
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @webmandesign. This fix worked for me. I was able to replicate the issue with a non-block theme by adding the following to functions.php
:
add_theme_support(
'editor-gradient-presets',
array(
array(
'name' => __( 'Red to transparent', 'test' ),
'gradient' => 'linear-gradient(135deg, rgba(255,0,0,.8) 0%, rgba(255,0,0,0) 100%)',
'slug' => 'red-to-transparent',
),
)
);
and the following css:
.has-red-to-transparent-gradient-background {
background-image: linear-gradient(135deg, rgba(255,0,0,.8) 0%, rgba(255,0,0,0) 100%);
}
Without this patch applied the default black background showed through the transparent part of the gradient instead of the background image:
With patch applied the image show through as expected in the editor and the frontend:
I also tested the following combinations on a non-block and blocked based theme and they all still functioned as expected with this patch applied:
- Cover with image showed default block overlay if no overlay color selected
- Cover with no image and solid overlay color selected
- Cover with image and solid overlay color selected
Given the recent issues with some of the Cover block CSS I think it would be good to get a second set of 👀 and approval on this before we merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @webmandesign! This is testing nicely for me, too, it looks like it essentially overwrites the background-color: $black
rule directly above it for those cases where the has-background-gradient
class is applied.
I suppose an alternative would be to add an additional chaining to the :not
rules above, but I quite like this separate rule as it's a bit more readable.
It also didn't look like the child combinator was necessary to me if you want to remove it (it seems to work well either way with nested cover blocks), so I'd be happy with it either way.
LGTM!
Thanks guys. I have updated the code and removed the child combinator. |
Description
Fixes #38764 by setting a transparent background color on a gradient overlay element so transparent gradient stops don't reveal a default black background color of an overlay.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).