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

Fix: $black background-color remains visible when there is no backg… #20904

Merged
merged 1 commit into from
Apr 9, 2020
Merged

Fix: $black background-color remains visible when there is no backg… #20904

merged 1 commit into from
Apr 9, 2020

Conversation

ferdiesletering
Copy link
Contributor

@ferdiesletering ferdiesletering commented Mar 14, 2020

…round dim with transparent images.

Description

When setting the background opacity to 0 with a PNG transparent image the background remains black.

Screenshots

Current

bug

Fix

fix

Types of changes

Bug fix

Checklist:

  • My code follows the WordPress code style. <!-- Check code: npm run lint, Guidelines:

@jasmussen
Copy link
Contributor

This is an excellent PR, thank you! But instead of setting the color to transparent (this increases CSS selector specificity) — I feel like it's important to ask the question: why was the background black in the first place?

I will take a guess: because for the longest time it only supported images, and given the text was white by default, it felt natural to pair that with a black background.

However given we now support both color-only backgrounds, gradient-only backgrounds, and either of those as overlays, there doesn't seem to be a use case for it in the first place.

cover without black bg

And if we remove the black, you can get yourself into trouble if you really want to — if you kept typing here the white text would overlay a white background (this cover shows a blue square with transparency outside of it):

Screenshot 2020-04-01 at 09 52 12

However you could get yourself in trouble regardless, and there's no way we could ever protect you from that. The theme could be a dark theme, or the text could be set to an in-opportune color.

I say: remove line 4 in cover/styles.scss entirely!

However I would like a sanity check from @jorgefilipecosta first, as I know he's worked with some of this.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jasmussen, @ferdiesletering, I think we set the background color to black because by default there is some opacity.

I think the fix is to move background-color: black to be applied only when there is no opacity e.g: move the line four of style.scss to:

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

@ferdiesletering
Copy link
Contributor Author

@jasmussen @jorgefilipecosta thank you for constructive feedback 🙏
Could you recheck the PR?

@jasmussen jasmussen self-requested a review April 8, 2020 11:05
Copy link
Contributor

@jasmussen jasmussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

This is with the most recent code:

dim

Note that dimming works. The shift from 10% to zero may not be the most intuitive, but most should not see this, and it supports the use case where you want the transparency from the PNG image, as you noted.

I also confirmed that dimming would have been broken if we had simply removed the background color entirely:

no bg

@jorgefilipecosta jorgefilipecosta added [Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Bug An existing feature does not function as intended labels Apr 9, 2020
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good 👍 Thank you for working on this @ferdiesletering!

@jorgefilipecosta jorgefilipecosta merged commit ce91154 into WordPress:master Apr 9, 2020
@github-actions github-actions bot added this to the Gutenberg 7.9 milestone Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants