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

fix: account for when no good color can be found #64

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

liamdebeasi
Copy link
Owner

@liamdebeasi liamdebeasi commented Apr 12, 2024

Sometimes the color adjustment tool can't find a good color within the chosen color palette such that the contrast meets a ratio of 4.5:1. In those cases we fallback to using either white or black, whichever one yields the higher contrast.

Example:

Background: #ffffff
Foreground: #fffbb9

Technically #707070 is sufficient here as a background, but the color adjust util does not seem to choose that. There may be opportunity for improvement here by modifying how the tool chooses colors. However, this fallback at least ensures adjusted colors meet the 4.5:1 contrast ratio.

Interestingly, using #ebebeb (slightly darker than white) as the background does not reproduce the issue.

@liamdebeasi liamdebeasi marked this pull request as ready for review April 12, 2024 02:23
@liamdebeasi liamdebeasi merged commit f38d274 into main Apr 12, 2024
1 check passed
@liamdebeasi liamdebeasi deleted the adjust-color-lightness-too branch April 12, 2024 02:25
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