feat(avatar): migrate avatar component to S2#6113
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
e240a53 to
1bc7a15
Compare
c1c7ad2 to
213450c
Compare
…lement
Per the accessibility migration analysis:
- Set aria-hidden="true" on the host (<swc-avatar>) when alt="" so the
entire shadow tree is reliably hidden from AT across JAWS/NVDA/VoiceOver
- Consolidate the alt-change logic in updated() to sync aria-hidden and
fire the missing-alt DEBUG warning in a single changes.has('alt') branch
- Improve alt JSDoc to explain the host aria-hidden behavior and clarify
that omitting alt only differs from decorative by the DEBUG warning
Closes: accessibility checklist items in migration-plan.md
…breaking changes note
213450c to
de8b3f7
Compare
Description
Migrates
sp-avatarto 2nd-genswc-avataras part of the Spectrum 2 component migration epic.What's included:
2nd-gen/packages/core/components/avatar/) —AvatarBaseclass withsrc,alt,size,showStroke, anddisabledproperties;AvatarSizetype andAVATAR_VALID_SIZESconstant;labelcompatibility shim with DEBUG deprecation warning
2nd-gen/packages/swc/components/avatar/) —Avatarconcrete class extendingAvatarBase;S2-aligned CSS using design tokens for all 17 sizes (50–1500);
show-strokeoutline support;disabledreduced-opacity state
Accessibility stories; breaking-changes table in component JSDoc; full argType defaults
aria-hiddentoggling, disabled state, and DEBUG warnings; 6 Playwright ARIA snapshot testsmigration.mdconsumer migration guide; migration plan with all phases completeSpectrumElementinfrastructure members (dir,VERSION,CORE_VERSION,hasVisibleFocusInTree) from every component's Storybook API tableMotivation and context
swc-avataris the Spectrum 2 implementation of the avatar component. Key changes from 1st-gen:label→alt,is-decorative→alt="", linked variant removed (wrap in<a>instead), default size changed from100to500, size scale extended to 1500,disabledstate retained (now applies to any avatar at reducedopacity rather than only the linked variant).
Related issue(s)
Author's checklist
CONTRIBUTING and
PULL_REQUESTS documents.
Practices
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Default labeled avatar renders as a circle with correct alt text
<swc-avatar>— confirmsizeattribute is500and noaria-hiddenattribute ispresent
<img alt="Jane Doe">is presentDecorative avatar is hidden from the accessibility tree
aria-hidden="true"is present on the<swc-avatar>host elementimgrole appears in the browser's accessibility tree inspectorshow-strokeoutline renders correctly on dark backgroundsDisabled avatar renders at reduced opacity
disabledattribute is present on the<swc-avatar>host elementAll 17 sizes render correctly
Accessibility testing checklist
Keyboard —
swc-avataris a static, non-interactive element and receives no focus on its own.Keyboard accessibility for linked avatars is provided by a wrapping
<a>.swc-avataris skipped entirely (not in tab order)<button>and Enter/Spaceactivate it
Screen reader —
swc-avatarexposes animgrole withalttext through the shadow DOM.aria-hidden="true")AT)