-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rule): add new color-contrast-enhanced rule (WCAG AAA) (#3235)
* test commit 1 * Revert "test commit 1" This reverts commit 9f996bc. * fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-interactive" Closes issue #2934 * feat(rule): add new rule color-contrast-enhanced (WCAG AAA) Work in progress. * Work in progress. * Work in progress. * Updating shadow-dom test for WCAG AAA contrast. * Rearranging shadow-dom test. * Adding new rule color-contrast-enhanced to code-highlighting test. * adding new 'color-contrast-enhanced' rule to sticky-header test. * Revert "fix(rule): allow "tabindex=-1" for rules "aria-text" and "nested-interactive"" This reverts commit 30f0e01. * update rule-descriptions.md * fix whitespace Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * work in progress: splitting tests for contrast and the new contrast-enhanced. * work in progress: tests * work in progress: tests * work in progress: tests * adding separate tests for color-contrast-enhanced. work in progress. * update rule-descriptions.md * add test: test/integration/full/contrast-enhanced/simple.html * remove redundant tests for contrast-enhanced * remove temporary code Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
- Loading branch information
1 parent
4bf7d35
commit bec20fc
Showing
15 changed files
with
362 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"id": "color-contrast-enhanced", | ||
"evaluate": "color-contrast-evaluate", | ||
"options": { | ||
"ignoreUnicode": true, | ||
"ignoreLength": false, | ||
"ignorePseudo": false, | ||
"boldValue": 700, | ||
"boldTextPt": 14, | ||
"largeTextPt": 18, | ||
"contrastRatio": { | ||
"normal": { | ||
"expected": 7 | ||
}, | ||
"large": { | ||
"expected": 4.5 | ||
} | ||
}, | ||
"pseudoSizeThreshold": 0.25, | ||
"shadowOutlineEmMax": 0.1 | ||
}, | ||
"metadata": { | ||
"impact": "serious", | ||
"messages": { | ||
"pass": "Element has sufficient color contrast of ${data.contrastRatio}", | ||
"fail": { | ||
"default": "Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}", | ||
"fgOnShadowColor": "Element has insufficient color contrast of ${data.contrastRatio} between the foreground and shadow color (foreground color: ${data.fgColor}, text-shadow color: ${data.shadowColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}", | ||
"shadowOnBgColor": "Element has insufficient color contrast of ${data.contrastRatio} between the shadow color and background color (text-shadow color: ${data.shadowColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}" | ||
}, | ||
"incomplete": { | ||
"default": "Unable to determine contrast ratio", | ||
"bgImage": "Element's background color could not be determined due to a background image", | ||
"bgGradient": "Element's background color could not be determined due to a background gradient", | ||
"imgNode": "Element's background color could not be determined because element contains an image node", | ||
"bgOverlap": "Element's background color could not be determined because it is overlapped by another element", | ||
"fgAlpha": "Element's foreground color could not be determined because of alpha transparency", | ||
"elmPartiallyObscured": "Element's background color could not be determined because it's partially obscured by another element", | ||
"elmPartiallyObscuring": "Element's background color could not be determined because it partially overlaps other elements", | ||
"outsideViewport": "Element's background color could not be determined because it's outside the viewport", | ||
"equalRatio": "Element has a 1:1 contrast ratio with the background", | ||
"shortTextContent": "Element content is too short to determine if it is actual text content", | ||
"nonBmp": "Element content contains only non-text characters", | ||
"pseudoContent": "Element's background color could not be determined due to a pseudo element" | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "color-contrast-enhanced", | ||
"matches": "color-contrast-matches", | ||
"excludeHidden": false, | ||
"enabled": false, | ||
"tags": ["cat.color", "wcag2aaa", "wcag146"], | ||
"metadata": { | ||
"description": "Ensures the contrast between foreground and background colors meets WCAG 2 AAA contrast ratio thresholds", | ||
"help": "Elements must have sufficient color contrast" | ||
}, | ||
"all": [], | ||
"any": ["color-contrast-enhanced"], | ||
"none": [] | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.