-
Notifications
You must be signed in to change notification settings - Fork 841
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
[EuiAvatar] Calculate high-contrast text against background #7824
Comments
@1Copenut Has this come up in any of our accessibility audits of Kibana? |
Thank you for bringing it to our attention. This is a valid accessibility issue, but not one we can prioritize at the moment. We would accept a PR for this, however, which adds a simple color contrast detection and warning as seen in the Badge. |
👋 Thank you for your suggestion or request! While the EUI team agrees that it's valid, it's unlikely that we will prioritize this issue on our roadmap. We'll leave the issue open if you or anyone else in the community wants to implement it by contributing to EUI. If not, this issue will auto close in one year. |
@JasonStoltz if no one is working on this issue, I would like to take it, I am new contributor to this repo, thanks! |
@Arup-Chauhan if an issue has not been assigned to an EUI team member, it's free to pick up by any open source contributor - simply open a PR against our repo. Please see our contributing guidelines for more! https://github.com/elastic/eui/tree/main/wiki/contributing-to-eui |
Hi @cee-chen , sure, so would you be assigning me this issue to work upon? Also, can I raise a draft PR to work on this issue? I have some initial questions on how to do it and also, I can get a feedback on my work underway. |
No, we do not assign issues to non-EUI contributors. Please see our linked wiki above again:
It also answers your question about draft PRs - they are very welcome. You will want to |
Oh, sure no problem, I will make a draft PR and get started, will ask questions there only, thanks! |
Signed-off-by: Arup Chauhan <[email protected]>
Signed-off-by: Arup Chauhan <[email protected]>
@cee-chen I have added a comment in the draft PR for to this, can you please check it once? |
Please disregard the noise/issue closure - stalebot went rogue due to misconfiguration. |
Thanks @cee-chen , I will continue work on this |
Summary
Within the Avatar component, for the purposes of rendering initials, the text colour is selected based either the selected or generated background colour:
eui/packages/eui/src/components/avatar/avatar.tsx
Lines 164 to 168 in 8e35923
Currently, the logic simplistically chooses white (for dark backgrounds) or black (for light backgrounds), this won't necessarily provide a sufficient contrast against some background colours. Neither is there support for explicitly setting the text colour.
A similar issue applies to the Badge component:
eui/packages/eui/src/components/badge/color_utils.ts
Lines 60 to 66 in 7fac1ce
Albeit inconsistent with Avatar, the Badge component does at least raise a contrast warning:
eui/packages/eui/src/components/badge/badge.tsx
Lines 142 to 153 in 7fac1ce
Acceptance Criteria
Fortunately, an existing utility function already exists within the EUI component library for calculating an appropriate contrasting colour: makeHighContrastColor.
The text was updated successfully, but these errors were encountered: