feat(meter): scaffold 2nd-gen meter (setup, API, a11y, styling) — SWC-2008..2011#6316
feat(meter): scaffold 2nd-gen meter (setup, API, a11y, styling) — SWC-2008..2011#6316blunteshwar wants to merge 1 commit into
Conversation
Implements SWC-2008, SWC-2009, SWC-2010, and SWC-2011 against the meter migration plan, targeting the long-lived `meter-migration` integration branch. - SWC-2008 (Setup): core/swc file structure, package.json exports, shared/linear-progress-base.css stub. - SWC-2009 (API): LinearProgressMixin holds value clamping, fill-fraction, Intl.NumberFormat locale formatting via LanguageResolutionController, label/description slot tracking, and DEBUG-mode accessible-name warning. MeterBase adds variant + DEBUG variant validation. - SWC-2010 (A11y): role="meter" on shadow `.swc-Meter` (host carries no ARIA); aria-valuemin/max/now/text on role element; label slot -> aria-labelledby with accessibleLabel fallback -> aria-label; description slot -> aria-describedby; non-focusable. - SWC-2011 (Styling): ports spectrum-css spectrum-two progressbar + meter to swc-Meter namespace, replaces --mod-* with --swc-meter-* tokens, covers variants, sizes, side-label, static white/black, forced-colors. Stylelint clean; ESLint clean; Prettier clean; build green. Known deferrals: - Shared CSS inlined in meter.css; lift-out to swc/shared/linear-progress-base.css happens when <swc-progress-bar> migrates (vite postcss pipeline lacks postcss-import; no other 2nd-gen component uses @import). - Description container always emitted with `is-empty` class so the <slot> stays mounted for reliable slotchange (full conditional render loses slotchange across content-add transitions). - Stories and tests scaffolded under SWC-2013 / SWC-2014. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
📚 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 |
Description
Scaffolds the 2nd-gen
<swc-meter>against the approved migration plan, covering four sequential phase tickets (Setup, API, Accessibility, Styling). Targets the long-livedmeter-migrationintegration branch — notmain. Subsequent phase tickets (conformance, testing, documentation, consumer migration guide, final review) ship as follow-up PRs into the same base.Phases delivered:
package.jsonexports for@spectrum-web-components/core/components/meter,swc/shared/linear-progress-base.cssstub.LinearProgressMixinowns value clamping, fill-fraction,Intl.NumberFormatlocale formatting viaLanguageResolutionController,label/descriptionslot tracking, and the DEBUG-mode accessible-name warning.MeterBaseaddsvariantplus DEBUG variant validation.formatOptionsis a JS-onlyIntl.NumberFormatOptionspass-through.role="meter"on the shadow.swc-Meterwrapper (host carries no ARIA);aria-valuemin/aria-valuemax/aria-valuenow/aria-valuetexton the role element;labelslot →aria-labelledby,accessibleLabel→aria-labelfallback when no label slot,descriptionslot →aria-describedby; non-focusable.spectrum-cssspectrum-twoprogressbar/index.css+meter/index.cssto theswc-Meternamespace, replaces all--mod-*with--swc-meter-*tokens, covers variants (informative/positive/notice/negative), sizes (s/m/l/xl),label-position="side",static-color="white"/"black", and a forced-colors block. Stylelint, ESLint, and Prettier all clean; build green.Motivation and context
Phase-1 plan is merged via #6215. This PR is the first implementation pass against that plan. ARIA contract follows the binding decisions in
CONTRIBUTOR-DOCS/03_project-planning/03_components/meter/accessibility-migration-analysis.md(role on shadow, label slot +accessibleLabelfallback, description slot, no host ARIA).Related issue(s)
Known deferrals
meter.cssfor this PR; the lift-out toswc/shared/linear-progress-base.csshappens when<swc-progress-bar>migrates (vite's postcss pipeline does not includepostcss-import, and no other 2nd-gen component uses@import).is-emptyclass instead of being fully omitted vianothing, so the<slot>stays mounted andslotchangefires reliably when content is added at runtime. ARIA-describedby is still gated on the tracked flag, and the empty container is hidden via CSS.meter.stories.tsormeter.test.ts.Author's checklist
main.)Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Default meter renders with role="meter" on the shadow
.swc-Meter.2nd-gen(yarn build:2nd-gen).@adobe/spectrum-wc/components/meter/swc-meter.jsin a sandbox page.<swc-meter value="40"><span slot="label">Storage used</span></swc-meter>.role="meter"only on the inner.swc-Meterelement; the host element has noroleattribute.aria-valuemin="0",aria-valuemax="100",aria-valuenow="40",aria-valuetextmatches the rendered percent.Accessible name resolves from the label slot.
aria-labelledbypointing at the shadow id of the label container.accessible-label="Storage usage".aria-label="Storage usage"andaria-labelledbyis absent.Variants and sizes apply S2 tokens.
variantvaluesinformative,positive,notice,negativeacross sizess,m,l,xl.*-visual-colortokens (andaccent-content-color-defaultforinformative) and bar thickness matches the size token.Static color and side label.
<swc-meter value="50" static-color="white" label-position="side">...</swc-meter>against a dark background.static-white-*tokens and the label sits inline with the bar.Device review
Accessibility testing checklist
Keyboard (required — document steps below)
<swc-meter>instances at varying values.Screen reader (required — document steps below)
<swc-meter value="40" variant="positive"><span slot="label">Storage used</span><span slot="description">2 GB of 5 GB used</span></swc-meter>in NVDA / JAWS / VoiceOver.40%inen-US, Arabic-Indic digits +٪inar-sa), and the description text.accessible-label="Storage usage"and confirm the announcement now uses that name instead, witharia-labelledbyno longer referenced.🤖 Generated with Claude Code