a11y(badge): add optional sr-only prefix and ensure labels are never color-only#470
Open
samjay8 wants to merge 1 commit into
Open
a11y(badge): add optional sr-only prefix and ensure labels are never color-only#470samjay8 wants to merge 1 commit into
samjay8 wants to merge 1 commit into
Conversation
…color-only Gives status badges screen-reader context (e.g. "Bond status: Slashed") without changing the visible API or contrast. - Add srPrefix?: string prop — renders an .sr-only <span> before the visible label so assistive tech announces the badge in context; no extra DOM when omitted - Add title attribute matching displayLabel for truncation tooltips - Trim trailing whitespace from the badge root className concatenation - Replace misnamed Badge.test.tsx (which tested Banner) with a correct Badge test suite covering: variant normalization, label override, title attribute, className, srPrefix DOM and accessible-name assertions, and a color-only regression guard that asserts every severity variant has a non-empty label - Update docs/COMPONENTS.md Badge entry with srPrefix prop, usage example, and accessibility guidance Closes CredenceOrg#444
|
@samjay8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #444
Summary
Gives status badges screen-reader context (e.g.
"Bond status: Slashed") without changing the visible API or contrast ratios.Changes
src/components/Badge.tsxsrPrefix?: stringprop - renders an.sr-only<span>before the visible label so assistive technology announces the badge in context (e.g.srPrefix="Bond status:"reads as"Bond status: Slashed"); no extra DOM when omittedtitleattribute matchingdisplayLabelfor truncation tooltip supportclassNameconcatenation (now uses.trim())src/components/Badge.test.tsxlabeloverride,titleattribute for all variants,classNameprop,srPrefixDOM and accessible-name assertions, and a color-only regression guard asserting every severity variant has a non-empty visible labeldocs/COMPONENTS.mdsrPrefixto the Badge props table with description and usage examplestitleattribute and color-alone guidanceTest plan
npm run lintpassesnpm run buildpassesnpm run testpasses (? 95% Badge branch coverage)