Skip to content

Simplify color specifications from rgba to rgb #70008

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

Merged

Conversation

georgestephanis
Copy link
Contributor

Currently, the theme.json that ships in core at wp-includes/theme.json default gradients are inconsistent in color specification -- a number of places it uses rgba(#,#,#,1) even though that is equivalent to just rgb(#,#,#) -- there is no rhyme or reason I can see as to why rgba is used here, so this is to trim a couple bytes by serving them up as rgb instead of rgba.

As there is no transparency here, it may be slightly more efficient to use hex? But I'm fine leaving it as RGB for less code churn in core unless anyone feels strongly here.

Why?

Simplifying color specifications in core boilerplates -- more consistency in code style standards.

How?

Dropping the opacity specification when it's full opacity.

Testing Instructions

  • Shouldn't be much needed, gradients should show normally.

Currently, the theme.json that ships in core at `wp-includes/theme.json` default gradients are inconsistent in color specification -- a number of places it uses `rgba(#,#,#,1)` even though that is equivalent to just `rgb(#,#,#)` -- there is no rhyme or reason I can see as to why rgba is used here, so this is to trim a couple bytes by serving them up as rgb instead of rgba.

As there is no transparency here, it may be slightly more efficient to use hex?  But I'm fine leaving it as RGB for less code churn in core unless anyone feels strongly here.
Copy link

github-actions bot commented Apr 28, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: georgestephanis <georgestephanis@git.wordpress.org>
Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Apr 29, 2025
@Mamaduka
Copy link
Member

cc @WordPress/block-themers

Copy link
Member

@juanfra juanfra left a comment

Choose a reason for hiding this comment

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

Good catch! Thanks for your PR.

Looks good to me. I saw that in TT4's theme.json we use hex values for gradients, so we may want to consider that for consistency.

@georgestephanis
Copy link
Contributor Author

georgestephanis commented Apr 30, 2025

Happy to see us switch over to it -- especially as hex now supports alpha transparency if needed.

@Mamaduka Mamaduka added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Apr 30, 2025
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thank you, @georgestephanis and @juanfra!

@Mamaduka Mamaduka merged commit 92860fa into WordPress:trunk Apr 30, 2025
70 of 73 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.8 milestone Apr 30, 2025
@t-hamano
Copy link
Contributor

t-hamano commented May 1, 2025

@georgestephanis Thanks for working on this!

Do you have the bandwidth to submit a core ticket and patch? The lib/theme.json is not automatically synced to core, so to reflect this change in the next WordPress 6.9 release, we will need to update the theme.json in core directly.

@georgestephanis
Copy link
Contributor Author

Sure, I'll get it in today.

@georgestephanis
Copy link
Contributor Author

Trac ticket that ^^ is for:

https://core.trac.wordpress.org/ticket/63381

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request May 13, 2025
…on`.

`rgba(#,#,#,1)` is equivalent to `rgb(#,#,#)` and can be replaced with the latter for more consistency.

Original PR from Gutenberg repository:
* [WordPress/gutenberg#70008 #70008 Simplify color specifications from rgba to rgb]

Follow-up to [50959], [55405].

Props georgestephanis, wildworks, juanfra.
Fixes #63381.

git-svn-id: https://develop.svn.wordpress.org/trunk@60234 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request May 13, 2025
…on`.

`rgba(#,#,#,1)` is equivalent to `rgb(#,#,#)` and can be replaced with the latter for more consistency.

Original PR from Gutenberg repository:
* [WordPress/gutenberg#70008 #70008 Simplify color specifications from rgba to rgb]

Follow-up to [50959], [55405].

Props georgestephanis, wildworks, juanfra.
Fixes #63381.
Built from https://develop.svn.wordpress.org/trunk@60234


git-svn-id: http://core.svn.wordpress.org/trunk@59570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request May 13, 2025
…on`.

`rgba(#,#,#,1)` is equivalent to `rgb(#,#,#)` and can be replaced with the latter for more consistency.

Original PR from Gutenberg repository:
* [WordPress/gutenberg#70008 #70008 Simplify color specifications from rgba to rgb]

Follow-up to [50959], [55405].

Props georgestephanis, wildworks, juanfra.
Fixes #63381.
Built from https://develop.svn.wordpress.org/trunk@60234


git-svn-id: https://core.svn.wordpress.org/trunk@59570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
* Simplify color specifications from `rgba` to `rgb`

Currently, the theme.json that ships in core at `wp-includes/theme.json` default gradients are inconsistent in color specification -- a number of places it uses `rgba(#,#,#,1)` even though that is equivalent to just `rgb(#,#,#)` -- there is no rhyme or reason I can see as to why rgba is used here, so this is to trim a couple bytes by serving them up as rgb instead of rgba.

As there is no transparency here, it may be slightly more efficient to use hex?  But I'm fine leaving it as RGB for less code churn in core unless anyone feels strongly here.

* Update test to account for changed default.

Co-authored-by: georgestephanis <georgestephanis@git.wordpress.org>
Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants