Skip to content

Skip color-mix(…) when opacity is 100% #17815

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
merged 4 commits into from
Apr 28, 2025

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Apr 28, 2025

This PR improves colors with alpha values where the alpha value results in 100%.

Before this change, a class like bg-red-500/100 would be generated as:

.bg-red-500\/100 {
  background-color: #ef4444;
}

@supports (color: color-mix(in lab, red, red)) {
  .bg-red-500\/100 {
    background-color: color-mix(in oklab, var(--color-red-500) 100%, transparent);
  }
}

But we don't need the color-mix, or the fallback styles at all in case the alpha value is 100%.

After this change the bg-red-500/100 class will generate as:

.bg-red-500\/100 {
  background-color: var(--color-red-500);
}

Which is essentially the same as bg-red-500, but we can migrate that away in the future. At least the generated CSS is smaller.

Test plan

  1. Added a test to ensure the generated value doesn't include color-mix at all.

@RobinMalfait RobinMalfait requested a review from a team as a code owner April 28, 2025 17:21
@@ -26032,7 +26042,7 @@ describe('spacing utilities', () => {

describe('custom utilities', () => {
test('custom static utility', async () => {
let { build } = await compile(css`
Copy link
Contributor

Choose a reason for hiding this comment

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

These format changes seem weird

Copy link
Contributor

Choose a reason for hiding this comment

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

Did Prettier update and change this or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was too quick to quit vim and prettier didn't run in time 😂

@RobinMalfait RobinMalfait force-pushed the fix/remove-color-mix-for-opacity-100 branch from 4079e70 to c788f42 Compare April 28, 2025 17:26
@RobinMalfait RobinMalfait enabled auto-merge (squash) April 28, 2025 17:27
@RobinMalfait RobinMalfait merged commit d2daf59 into main Apr 28, 2025
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/remove-color-mix-for-opacity-100 branch April 28, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants