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

Gradient backgrounds should be set with background-image instead of background #32787

Open
justintadlock opened this issue Jun 17, 2021 · 7 comments · May be fixed by #35036
Open

Gradient backgrounds should be set with background-image instead of background #32787

justintadlock opened this issue Jun 17, 2021 · 7 comments · May be fixed by #35036
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@justintadlock
Copy link
Contributor

I have been attempting some work with background-clip: text like so:

-webkit-background-clip: text;
-webkit-text-fill-color: transparent; 
-moz-background-clip: text;
-moz-text-fill-color: transparent;

To create a gradient effect on text like this:

gradient-text

However, this does not work when using either gradient presets or a custom gradient. Both use background: $gradient instead of background-image: $gradient in the CSS output. By changing those to use background-image, the effect works.

I'm not sure if there are any historical reasons for going with background, but I'd love to see us move to only targeting background-image.

@Azragh
Copy link

Azragh commented Jun 18, 2021

Agreed. background: affects

background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-repeat
background-size

IMHO it's bad practice to use shorthand properties in inline styles alltogether.

@talldan talldan added CSS Styling Related to editor and front end styles, CSS-specific issues. Good First Issue An issue that's suitable for someone looking to contribute for the first time labels Jun 22, 2021
@pbearne
Copy link
Contributor

pbearne commented Oct 28, 2021

Hi all

I have started this but it seems that that change the background to background-color(or backgroundColor in js) if it is a straight color and to background-image(backgroundImage) if gradient

this change is in 100's of files so I what to reach back to make sure that me removing all the shorthand background is what you need/want

note: the only shorthand background have left is background: none

here is the branch I have started https://github.com/pbearne/gutenberg/tree/%2332787_replace_background_css_with_background-(type)

@skorasaurus
Copy link
Member

PR for this is also at #35036

@carolinan carolinan removed their assignment Nov 3, 2022
@priethor priethor linked a pull request Dec 8, 2022 that will close this issue
3 tasks
@bph
Copy link
Contributor

bph commented Jul 27, 2023

@ajlende Is this is something you could take on... ?

@devanshijoshi9
Copy link
Contributor

Hi @ajlende 👋 I have raised a new PR for this enhancement as some other components also have gradient background. Could you please review and let me know if any further modification is required? Thank you.

PR - #57246

@justintadlock
Copy link
Contributor Author

@devanshijoshi9 - I believe this needs to be fixed in the Style Engine. It's not just a fix in the CSS files. Specifically, this ticket deals with presets and other values set on a block as a background gradient.

@ramonjd
Copy link
Member

ramonjd commented Apr 3, 2024

I've added this to the task list for background image block supports:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
10 participants