Dynamically darken the default yiq-text-dark
HEX value if it does not pass a11y contrast ratio requirements
#2089
Labels
yiq-text-dark
HEX value if it does not pass a11y contrast ratio requirements
#2089
Description
The
colorYiq
Sass helper function helps determine what the foreground color should be (e.g., text color) given an input color to ensure an accessible contrast ratio.If the computed
yiq
value exceeds thecontrastThreshold
, it'll return the dark color specified intokens/src/global/other.json
via theyiq-text-dark
property which is a static HEX value color:paragon/tokens/sass-helpers.js
Lines 33 to 38 in 577ac74
Given that, there is currently no guarantee the static HEX value for
yiq-text-dark
has a suitable contrast ratio given the dynamic input color.Consider adding validation to dynamically modify the
yiq-text-dark
value if the HEX value specified inother.json
by using ChromaJS's darken functions to compute an a11y-friendly foreground color based on the default HEX value should the default HEX value not have a sufficient contrast ratio already.For example, we may use ChromaJS to detect the contrast between the dynamic
color
and theyiq-text-dark
, and if it's smaller than 4:5:1, run.darken()
or some other helper function to attempt to darken it to a sufficient contrast ratio.Acceptance Criteria
The text was updated successfully, but these errors were encountered: