Skip to content

Allow high-contrast input colors to be used as-is #3209

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 1 commit into from
May 2, 2025

Conversation

zenoachtig
Copy link
Contributor

For step 9 of the color scale, we try to respect the user's chosen color, unless it really isn't accessible. We use a lightness check and if the color is within 20% of the target lightness, we allow it to be used even if it doesn't exactly match.

This PR changes the logic of this check slightly to no longer restrict the lower and higher contrast bounds, but only the lower bound. In practice, it means that if you have a color that is higher contrast than needed, it will now be used as-is instead of being reduced to a less-contrasting version.

This is particularly useful if you set the primary color to black on light mode, or white on dark mode. Before this would result in a grey color being used for your buttons, but now you can get exact blacks or whites since they are more contrasting anyway.

Before

CleanShot 2025-05-02 at 19 25 35@2x

After

CleanShot 2025-05-02 at 19 25 40@2x

Copy link

changeset-bot bot commented May 2, 2025

🦋 Changeset detected

Latest commit: 9f46181

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

This PR includes changesets to release 2 packages
Name Type
@gitbook/colors Patch
gitbook Patch

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

@zenoachtig zenoachtig changed the title Change lightness check for color step 9 to allow input colors with a higher-than-needed contrast Allow high-contrast input colors to be used as-is May 2, 2025
Copy link

argos-ci bot commented May 2, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v1 (Inspect) 👍 Changes approved 18 changed May 2, 2025, 5:32 PM
customers-v2 (Inspect) 👍 Changes approved 18 changed May 2, 2025, 5:34 PM
default (Inspect) 👍 Changes approved 6 changed May 2, 2025, 5:36 PM
v2-vercel (Inspect) ✅ No changes detected - May 2, 2025, 5:37 PM

@zenoachtig zenoachtig merged commit f7a3470 into main May 2, 2025
20 checks passed
@zenoachtig zenoachtig deleted the allow-high-contrast-colors-scale-step-9 branch May 2, 2025 17:41
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