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

Improve gamut clamping #228

Merged
merged 3 commits into from
Mar 25, 2024
Merged

Improve gamut clamping #228

merged 3 commits into from
Mar 25, 2024

Conversation

drwpow
Copy link
Collaborator

@drwpow drwpow commented Mar 25, 2024

Changes

  • Adds 🆕 color.gamut option that lets you clamp to sRGB or P3 colorspace without rewriting your colors.
  • Fixes color.convertToHex where it wasn’t properly gamut clamping (hex by definition requires sRGB space; there’s no such thing as P3 hex colors)

How to Review

  • Tests added; tests should pass

Copy link

cloudflare-workers-and-pages bot commented Mar 25, 2024

Deploying cobalt-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: effbda2
Status: ✅  Deploy successful!
Preview URL: https://2451353b.cobalt-ui.pages.dev
Branch Preview URL: https://improve-gamut-clamping.cobalt-ui.pages.dev

View logs

Copy link

changeset-bot bot commented Mar 25, 2024

🦋 Changeset detected

Latest commit: effbda2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cobalt-ui/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

packages/core/src/parse/tokens-studio.ts Dismissed Show dismissed Hide dismissed
@@ -365,10 +369,65 @@ export function convertTokensStudioFormat(rawTokens: Record<string, unknown>): {
tokenPath,
);
} else {
let value: string | undefined = v.value;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is pretty hacky, but fixes an existing bug where rgba({colors.black}, 0.2) would get left as-is.

Does a little work to fix common scenarios, but is by no means exhaustive and there are still plenty of other broken scenarios I’m sure.

@drwpow drwpow merged commit 1e12d04 into main Mar 25, 2024
10 checks passed
@drwpow drwpow deleted the improve-gamut-clamping branch March 25, 2024 16:57
@github-actions github-actions bot mentioned this pull request Mar 25, 2024
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.

1 participant