Open contolini opened 4 months ago
If we do add an attribute to the SVGs, we should be able to add it via svgo by editing the config at https://github.com/cfpb/design-system/blob/main/svgo.config.js and adding something like https://svgo.dev/docs/plugins/add-attributes-to-svg-elements/
Yes? @willbarton recently generated an SVG icon audit that I can review to check if there are any non-decorative SVGs.
If SVGs are only decorative, then we can add an aria-hidden attribute using perhaps the script mentioned by @anselmbradford in the comment above
@anselmbradford So it looks like there are several instances of the warning icon without an accompanying text label on the site. For just three examples:
https://www.consumerfinance.gov/owning-a-home/conventional-loans/ https://www.consumerfinance.gov/about-us/blog/african-american-and-hispanic-borrowers-harmed-provident-will-receive-9-million-compensation/ https://www.consumerfinance.gov/about-us/blog/new-relief-for-renters/
I'd argue that these warning icons as used here are not decorative, as they're calling attention to information that the writer believes is important, and there is no accompanying text label to indicate as such, like "Warning" or "Note".
@sonnakim It looks like those three cases have vestigial svgs that need to be handled differently post- @willbarton's work. If I view each in the Wagtail admin, the icons disappear, which means they need to be removed anyway, right? Or rather, they'll automatically be removed the next time each of those pages is saved.
That said, if we do keep icons in this way, perhaps we could aria-hidden
the icons by default, and add hidden text for the cases where it is not decorative. So something like:
<div>
<svg aria-hidden="true" class="cf-icon-svg … >
<span class="u-visually-hidden">Note:</span>
</div>
If that was done via Wagtail, there would need to be a mechanism to add the hidden text content to accompany the icons.
@sonnakim It looks like those three cases have vestigial svgs that need to be handled differently post- @willbarton's work. If I view each in the Wagtail admin, the icons disappear, which means they need to be removed anyway, right? Or rather, they'll automatically be removed the next time each of those pages is saved.
Nevermind, these are okay. I was not on the main
branch and probably need to refresh my local database. I see them on content. The rest of the above comment is still applicable though.
Ok, we discussed and believe we should do an audit of notification svg instances and how they're used (these appear to be the only ones that might need a text label or aria label), and then plan accordingly
Are our SVG icons always decorative? If so, we should add
aria-hidden="true"
to the SVGs' source code. So far, I haven't been able to find an SVG icon on cf.gov that isn't also coupled with a link, heading, etc.The other option would be to add a
hidden
parameter to our svg loading function so that imported SVGs can optionally havearia-hidden="true"
when desired.See https://css-tricks.com/accessible-svg-icons/