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

Use of #rrggbbaa hex format for colors unnecessarily excludes older browsers #41358

Open
cbirdsong opened this issue May 26, 2022 · 3 comments
Open
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Colors Color management [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable

Comments

@cbirdsong
Copy link

cbirdsong commented May 26, 2022

Description

Colors are output as hex values with transparency (#rrggbbaa) when using the new opacity control1:

<!-- wp:group {"style":{"color":{"background":"#cf2d2d9c"}}} -->
<div class="wp-block-group has-background" style="background-color:#cf2d2d9c"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"color":{"background":"#ffc7f9b3"}}} -->
<div class="wp-block-group has-background" style="background-color:#ffc7f9b3"></div>
<!-- /wp:group -->

This format has less support than rgba() (~92% of recorded traffic compared to presumably almost 100%) and offers no tangible benefit over it. Absent that, rgba() should be preferred.

Additionally, rgba() is already what is generated for custom gradients:

<!-- wp:group {"style":{"color":{"gradient":"linear-gradient(135deg,rgba(202,247,129,0.53) 2%,rgba(114,207,126,0.78) 93%)"}}} -->
<div class="wp-block-group has-background" style="background:linear-gradient(135deg,rgba(202,247,129,0.53) 2%,rgba(114,207,126,0.78) 93%)"></div>
<!-- /wp:group -->

Simple color fills should behave the same way.

Step-by-step reproduction instructions

Set a color on a block, adjust the opacity, and look at the resulting markup.

Environment info

WordPress 6.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Footnotes

  1. And possibly other places I haven't noticed?

@markhowellsmead
Copy link

See also #40943.

@aristath
Copy link
Member

Personal opinion: I don't think there's anything wrong with colors defined like #rrggbbaa... 8-digit hex colors are supported by any and all browsers that WordPress supports. Gutenberg uses many modern CSS techniques such as calc(), :where(), CSS grids, flexbox and so on. None of them has 100% support... Flex has 96% support, while :where() is at 89.14% yet it's used everywhere - and rightly so.
We will never be at 100%, nor should we pursue such a thing if we really want to move forward and build for the next decade.

@cbirdsong
Copy link
Author

cbirdsong commented May 26, 2022

WordPress’ only explicit list of browser support was intended to apply to the admin area, not the front end of the site. See this discussion on CSS authoring practices and browser support:

However, the difference between those examples and this specific issue is that :where() and custom properties are (mostly) being used to solve problems with no existing easy solution1, while #rrggbbaa‘s use provides no benefit in comparison to an older more well-supported color format. There is no trade-off being made. It is only exclusionary.

Footnotes

  1. However, the implementation could be a lot better. It is best practice to supply fallback values when using modern CSS techniques, but there seems to be very little consideration of progressive enhancement in the CSS that ships with the editor. The end result of this is definitely problematic when considering how heavily :where() and custom properties are used.

@justintadlock justintadlock added [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable [Feature] Colors Color management labels May 26, 2022
@skorasaurus skorasaurus added the Browser Issues Issues or PRs that are related to browser specific problems label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Colors Color management [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable
5 participants