-
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
Use .has-background for Cover block consistently with all other blocks. Consider adding background type class to all blocks. #21439
Comments
The reason for this would be that originally It should possibly be renamed |
I'd question whether that latter assumption is really how folks are understanding this. It certainly is not how I imagined that class worked, and I doubt treating it as a universal "has any kind of background" class would break things. I'll reiterate my concerns about CSS madness without a universal .wp-block-group.has-background,
.wp-block-group.has-background-gradient,
.wp-block-group.has-background-video,
.wp-block-group.has-background-image,
.wp-block-group.has-background-pattern {
padding: 1.5rem;
} Yes, I could write Instead, what if we added a .wp-block-group.has-background {
padding: 1.5rem;
}
.wp-block-group.has-background-color {
padding: 2.5rem;
} So to put forth a concrete proposal:
|
There's some information on backwards compatibility here: In particular it says:
If I'm reading it right, changing the way I do think your proposal makes logical sense, but there has to be some care taken with those changes. |
It's possible that I'm missing something, but I can't find an example in the core block styles where adding Further, I still think this is more a bug breaking expected behavior rather than an enhancement. It feels like this needs more eyes. But if others agree, it does seem important to get this change in ASAP (5.5 or 5.4.X). |
A few bullets to clarify the proposal here (courtesy of @carolinan):
From my perspective, this seems like a decent path forward. In most cases, themes use the My only hesitation to following this approach would be if it would cause widespread breakage, but I think on the contrary, it's more likely to suddenly fix themes that had been thinking about the |
100% in favor of @kjellr's proposal. Another addition: add |
Is there a solution that wouldn't cause breakage across themes? Or alternatively one that allows a more gradual transition away from the problematic class name? |
I really think this needs to almost be reframed as a bug, given that I just noticed that the Cover block doesn't even use the While it's plausible that adding the Adding this class will be a big long-term help to theme developers and I think cause much less breakage than a change like the buttons block markup. |
I'm open to other opinions, but my opinion is that what's being proposed here prioritizes the life of developers over end users. It'd be good to see some other options being proposed that don't result in unknown consequences, like using new class names, and then gradually phasing out the old ones. |
Here is a list of 140 themes that uses Note that I added a space after background in the search to avoid catching things like If you want to see all of the results, there are 272 themes: I did not do an analysis. A very quick browse shows that the most common use is for adding padding to elements that has the class.
|
@talldan I'll just reiterate again that this feels more like a bug and making up for an oversight rather than an additional feature. I don't see how
Forcing developers to deal with an unclear and inconsistent naming scheme (see columns below) that requires producing very complicated selectors and long CSS rulesets is a recipe for bugs and bloated files which are both extremely negative outcomes for users. @carolinan report is super useful! I haven't exhaustively gone through it, but here are a few things I've noticed:
A another useful search is for The result of all this is that I'm even further convinced that theme authors have been using Finally, there are only for hits for Columns is already doing thisFurther calling out the need for standardization here, I can see that when using the Gutenberg plugin, the columns block adds TestingFinally, I created a cover block and added the ConclusionThere is already existing inconsistency and we need to resolve it somehow. Adding more classes feels like a solution that would lead to clutter and confusion so long as Feedback always welcome. |
Unqualified guess, the themes that uses CSS like |
@carolinan That was also my guess. Lucky for us, practically all of the most popular themes that have a rule like that are by @andersnoren of Chaplin and Twenty Twenty fame. Would you mind weighing in, Anders? How would this change impact your themes positively or negatively? |
Most of my themes that set a background color on Pretty much all of my themes style |
I am thinking that with global styles, we will also have a different way to add padding. |
This is officially a bug, as it is now clear that the Cover block is the only block not following this behavior. I've audited WP 5.5-rc2 for background-related classes and found the following:
Background Classes Audit{name} = placeholder for named colors and gradients Cover Block
Button
Media & Text
Columns
Group Block
Proposed SolutionTo reiterate:
Next Steps
|
Stopping by because I've been having issues understanding what the purpose of the |
I'm theming a site right now that uses both background colors and background gradients.
I'm having to write double the selectors to target any cover block (or presumably group block in the future) that has either a background color or background gradient because they don't share a selector. I have to style both
.has-background
and.has-background-gradient
.Solution: Always apply
.has-background
to a block that has a background color or gradient (or image or video #16660)The text was updated successfully, but these errors were encountered: