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

Dynamically darken the default yiq-text-dark HEX value if it does not pass a11y contrast ratio requirements #2089

Closed
2 tasks
Tracked by #246
adamstankiewicz opened this issue Feb 24, 2023 · 0 comments · Fixed by #2337
Closed
2 tasks
Tracked by #246
Assignees

Comments

@adamstankiewicz
Copy link
Member

adamstankiewicz commented Feb 24, 2023

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 the contrastThreshold, it'll return the dark color specified in tokens/src/global/other.json via the yiq-text-dark property which is a static HEX value color:

if (yiq >= contrastThreshold) {
return chroma(darkColor);
}
return chroma(lightColor);
}

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 in other.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 the yiq-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

@adamstankiewicz adamstankiewicz added this to the Design tokens with style-dictionary milestone Feb 24, 2023
@adamstankiewicz adamstankiewicz moved this from 📋 Backlog to 🔖 To Do in Paragon Working Group Feb 24, 2023
@viktorrusakov viktorrusakov self-assigned this Apr 11, 2023
@viktorrusakov viktorrusakov linked a pull request Jun 1, 2023 that will close this issue
10 tasks
@github-project-automation github-project-automation bot moved this from Backlog to Closed in Frontend Working Group Jun 2, 2023
@github-project-automation github-project-automation bot moved this from To Do to Done in Paragon Working Group Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants