test(color-handle): tests and docs (phases 6-7)#6465
Conversation
…(phase 6) - color-handle.test.ts (Storybook play tests): role-less/name-less host, color applied to the fill layer, adaptive border-alpha variable set, touch pointerdown/up/cancel open-close (mouse does not auto-open), disabled suppresses the loupe, and fill=false outline-only via the reflected boolean property. - Contrast-helper unit coverage (computeBorderAlpha, findMinAlpha, contrastRatio): parser yields no NaN across named/hex/rgb/hsl/rgba, floor fallback for invalid input, white-first floor vs escalation. Covers the PR-review parser concern with a regression test. - color-handle.a11y.spec.ts (Playwright): role-less/name-less host and built-in loupe SVG aria-hidden across chromium/firefox/webkit. Verified locally (Node 24.11.1): Vitest storybook 13 passed, Playwright a11y 12 passed. Also corrected the plan's B7 consumer path: outline-only is set via the `fill` property (reflected boolean), not `fill="false"`. Refs SWC-2137, SWC-2295
|
📚 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 |
- color-handle.mdx: Anatomy, Options (Colors, Fill), States, Behaviors (Adaptive contrast), Accessibility (features + best practices), and Upcoming features. Documents the handle as a visual primitive whose name/role/value/keyboard belong to the parent color-area/slider/wheel. - Stories: drop `autodocs` from Playground so the MDX is the single docs page (keep `dev`); finalize the Accessibility story. Public prop JSDoc already lives on ColorHandleBase and feeds the ApiTable; no public `--swc-*` properties, so no `@cssprop` tags. Consumer-facing breaking-change/migration notes are deferred to the consumer migration guide. `yarn lint:docs-pages` passes; Storybook shows a single docs entry. Refs SWC-2137, SWC-2295
Story prose lives in the per-component MDX (Behaviors section), not above story exports. Removes the JSDoc block flagged by the conformance pass.
Add the Spectrum 1 to Spectrum 2 upgrade guide for application developers: tag/import rename, removal of the `--mod-colorhandle-*` surface (no public replacement), the new `fill` attribute (outline-only via the property), and the automatic adaptive-border / grow-on-focus behavior. Accessibility stance is unchanged from 1st-gen (parent owns name/role/value/keyboard). Refs SWC-2137, SWC-2295
…r Handle Meta title used lowercase "Color handle", which does not match the component title "Color Handle" (Storybook titles are case-sensitive), so the guide did not nest under the component and left it rendering as a standalone node. Use title case to group it under Color Handle, matching Color Loupe.
The handle is position:absolute and centers on its containing block's origin via negative margins, so in the old 24x24 anchor it landed on the corner (misaligned with the centered caption) and an open loupe overflowed the frame. Anchor each handle to a zero-size relative point at the bottom-center of a fixed 48x96 box with headroom above, so the handle centers over its caption and the loupe stays inside the frame.
Description
Phases 6 (Testing) and 7 (Documentation) of the
sp-color-handle→swc-color-handlemigration, stacked on the Phase 2–5 work merged via #6443. No component behavior changes.Testing (Phase 6)
Unit / behavior (
test/color-handle.test.ts, Storybook play tests):role/aria-label/aria-labelledby/tabindex);colorapplied to the fill layer; adaptive--_swc-color-handle-border-alphaset.pointerdown/pointerup/pointercancelopen-close; mouse does not auto-open.disabledsuppresses the built-in loupe even whenopen.fill=falserenders outline-only (via the reflected boolean property).Contrast helper (
computeBorderAlpha/findMinAlpha/contrastRatio):NaNacross named/hex/rgb/hsl/rgba; floor fallback for invalid input; white-first holds the floor when white carries 3:1 and escalates otherwise. Regression test for the parser concern raised in feat(color-handle): scaffold 2nd-gen core/SWC structure (Phase 2&3) #6443 review.Accessibility (
test/color-handle.a11y.spec.ts, Playwright):aria-hiddenacross chromium/firefox/webkit.Documentation (Phase 7)
color-handle.mdx): Anatomy, Options (Colors, Fill), States, Behaviors (Adaptive contrast), Accessibility (features + best practices), and Upcoming features. Documents the handle as a visual primitive whose name/role/value/keyboard belong to the parent color-area/slider/wheel.autodocsfrom Playground so the MDX is the single docs page (keptdev); finalized the Accessibility story.ColorHandleBaseand feeds the Storybook<ApiTable />; no public--swc-*properties, so no@cssproptags.Motivation and context
Locks in the migrated behavior and the SWC-2295 adaptive-border logic with regression protection (answering the "no tests" feedback on #6443), and adds the Storybook docs page so the component is usable and understandable by others.
Related issue(s)
Verification
Local (Node 24.11.1): Vitest storybook project — 13 passed (5 play tests + 8 story smoke renders); Playwright a11y — 12 passed (3 browsers).
yarn lint:docs-pagespasses; Storybook shows a single color-handle docs entry (no duplicate).test-storybookaXe is blocked locally by an unrelated@swc/corenative-binding failure + stray-worktree jest haste collision; aXe still runs in CI.Out of scope / follow-ups
--mod-*removal,fillproperty-vs-attribute) lands in the dedicated consumer migration guide, not the per-component MDX.swc-color-area/-slider/-wheel) is migrated.Author's checklist
Accessibility testing checklist
Color handle is a non-interactive visual primitive; name/role/value/keyboard belong to the parent picker. This PR adds the a11y regression tests and docs rather than changing behavior.
Keyboard — no focusable parts on the handle itself (parent owns keyboard); confirm no focusable node is introduced.
Color Handle/Overview.Screen reader — handle exposes no role/name; built-in loupe SVG is
aria-hidden.Color Handle/Accessibility.