Repository navigation
Contrast: contrastFor="ui" checks non-text contrast (WCAG 1.4.11, 3:1) - #11
Open
palatinus-sb wants to merge 1 commit into
Open
palatinus-sb wants to merge 1 commit into
palatinus-sb wants to merge 1 commit into
Conversation
…) in the badge and the area line; the area line now reaches the edge it leaves through
contrastFor="ui" on ColorPicker, ColorField, Picker.Area and Picker.Contrast (React and Vue) checks
contrastWith for borders, icons and focus rings: the area line moves to 3:1 and the badge shows Pass / Fail.
The default ("text") is unchanged. Core adds contrastLevel(ratio, "ui"), contrastMinimum(target) and the
ContrastTarget type.
The area line used to stop at the last sampled column with a crossing, a few pixels short of the top or
bottom edge; it now ends on the edge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
contrastWithonly checks text contrast today. The color area draws its line at 4.5:1 and the badge shows AAA / AA / AA Large / Fail. Borders, icons, focus rings and other UI parts fall under WCAG 1.4.11 (non-text contrast) instead, which needs 3:1 and only has pass or fail. This PR adds an opt-in way to check for that.contrastFor="ui", onColorPicker,ColorField,Picker.AreaandPicker.Contrast, in React and Vue:PassorFail. It reusesdata-level="pass"/"fail", so there are no CSS changes."text", behaves exactly as before.Core:
contrastLevel(ratio, "ui")returns"Pass" | "Fail". Overloads keep the old return type for calls without a target.contrastMinimum(target)returns 4.5 or 3. React and Vue use it for the line, so the threshold isn't hard-coded twice.ContrastTarget = "text" | "ui".Fix to the existing line: the area line used to stop at the last sampled column that had a crossing. Where the boundary leaves through the top or bottom edge between two columns, that left the line a few pixels short of the edge. A 3:1 line makes this easy to see. The line now ends exactly on the edge, found by bisection along it. I checked every hue at both thresholds against white, black and gray backgrounds: all 2,099 lines start and end on an edge.
Tests:
Docs:
llms.txt,SKILL.md, the READMEs and the docs site pages are updated.Checklist
pnpm typecheckandpnpm --filter @colorshot/core testpasspnpm --filter @colorshot/playground test:e2epasses, for UI changespage.gototimeout incss-resets, fails the same way onmain.pnpm build && pnpm sizestays within budgetdata-partnames, behavior)pnpm changeset) if the published package changesllms.txtandskills/colorshot/SKILL.mdupdated if a prop or export changed