An open source design system that's fully customizable and agent ready
TypeScript
fix(DateInput): the touch column's edge fade stops at 70% opacity, so every row keeps AA contrast (#9878)
Christopher Chedeau72e85200bbd9
diff --git a/.changeset/touch-wheel-fade-aa.md b/.changeset/touch-wheel-fade-aa.mdnew file mode 100644index 0000000000..3741d0f068--- /dev/null+++ b/.changeset/touch-wheel-fade-aa.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] DateInput: under a finger, every row in view of the bottom-sheet picker's columns meets WCAG AA contrast; their edge fade is shallower.++@vjeuxdiff --git a/docs/specs/components/DateInput/DateInput.spec.md b/docs/specs/components/DateInput/DateInput.spec.mdindex 4cb8201910..196897858c 100644--- a/docs/specs/components/DateInput/DateInput.spec.md+++ b/docs/specs/components/DateInput/DateInput.spec.md@@ -397,8 +397,9 @@ reach the bound.Under a finger, each sheet wheel in DateInput, TimeInput, and DateTimeInput laysits rows flat at the scrolling column's pitch and fades them toward its edges,-without tipping or shrinking. Under a mouse, the scrolling column tips and fades-its rows on a scroll timeline.+without tipping or shrinking. The fade stops at 70% opacity at the edges, so+every row in view meets WCAG AA contrast in every shipped theme. Under a mouse,+the scrolling column tips and fades its rows on a scroll timeline.Rejected: a UIPickerView-style cylinder look.diff --git a/packages/core/src/DateInput/PickerWheel.tsx b/packages/core/src/DateInput/PickerWheel.tsxindex b868710834..2e39ee5f3c 100644--- a/packages/core/src/DateInput/PickerWheel.tsx+++ b/packages/core/src/DateInput/PickerWheel.tsx@@ -73,6 +73,12 @@ const UIKIT_SCALE = ROW_HEIGHT / picker.geometry.rowHeight;/** UIKit's rubber band dimension for the picker's table, at that pitch. */const RUBBER_BAND_DIMENSION = picker.geometry.rubberBandDimension * UIKIT_SCALE;+/**+ * The rows' opacity at the column's edges. At 0.7 the row four from the band+ * keeps 5:1 or more in every shipped theme, a margin over WCAG AA's 4.5:1.+ */+const FADE_FLOOR = 0.7;+const styles = stylex.create({// The scrolling column's box, band and rows (Wheel.tsx), moved by the// gesture system and the compositor instead of a native scroller.@@ -92,8 +98,7 @@ const styles = stylex.create({position: 'absolute',inset: 0,pointerEvents: 'none',- maskImage:- 'linear-gradient(to bottom, rgb(0 0 0 / 0.3), rgb(0 0 0) 50%, rgb(0 0 0 / 0.3))',+ maskImage: `linear-gradient(to bottom, rgb(0 0 0 / ${FADE_FLOOR}), rgb(0 0 0) 50%, rgb(0 0 0 / ${FADE_FLOOR}))`,},/*** The selection band: a centred row-height plate behind the rows.diff --git a/packages/core/src/DateInput/__snapshots__/PickerWheel.test.tsx.snap b/packages/core/src/DateInput/__snapshots__/PickerWheel.test.tsx.snapindex 37b06f0ab1..815596697e 100644--- a/packages/core/src/DateInput/__snapshots__/PickerWheel.test.tsx.snap+++ b/packages/core/src/DateInput/__snapshots__/PickerWheel.test.tsx.snap@@ -1,3 +1,3 @@// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html-exports[`PickerWheel — markup > keeps the touch column’s markup 1`] = `"<div role="listbox" aria-label="Hour" aria-activedescendant="_r_id_-10" tabindex="0" data-wheel="" class="PickerWheel__styles.column x1n2onr6 x1cqoux5 xeuugli xm8gem xb3r6kr x1a2a7pz x1i10hfl focusOutline__focusOutlineStyles.focusVisible x1k57tk5 x1vidyx5 x1t137rt x1jhp3zv xx47ajj x1wfwxd8 x1vwwbsn" data-astryx-touch-action="pan-x pinch-zoom"><div data-wheel-fade="" class="PickerWheel__styles.fade x10l6tqk x10a8y8t x47corl xheapza"><div aria-hidden="true" class="PickerWheel__styles.band x10l6tqk x17y0mx6 x7rbydg x6hpsvf xh6dtrn x17x4s8c x47corl"></div><div data-wheel-strip="" class="PickerWheel__styles.strip x10l6tqk x17y0mx6 x7rbydg x47corl" style="translate: 0px -280px;"><div id="_r_id_-0" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="00" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 0px;">00</div><div id="_r_id_-1" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="01" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 28px;">01</div><div id="_r_id_-2" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="02" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 56px;">02</div><div id="_r_id_-3" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="03" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 84px;">03</div><div id="_r_id_-4" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="04" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 112px;">04</div><div id="_r_id_-5" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="05" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 140px;">05</div><div id="_r_id_-6" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="06" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 168px;">06</div><div id="_r_id_-7" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="07" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 196px;">07</div><div id="_r_id_-8" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="08" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 224px;">08</div><div id="_r_id_-9" role="option" aria-selected="false" data-wheel-row="" data-label="09" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 252px;">09</div><div id="_r_id_-10" role="option" aria-selected="true" data-wheel-row="" data-label="10" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowActive xjse4m1 x2mo6ok" style="--x-insetBlockStart: 280px; color: var(--color-text-accent); font-weight: var(--font-weight-semibold);">10</div><div id="_r_id_-11" role="option" aria-selected="false" data-wheel-row="" data-label="11" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 308px;">11</div><div id="_r_id_-12" role="option" aria-selected="false" data-wheel-row="" data-label="12" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 336px;">12</div><div id="_r_id_-13" role="option" aria-selected="false" data-wheel-row="" data-label="13" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 364px;">13</div><div id="_r_id_-14" role="option" aria-selected="false" data-wheel-row="" data-label="14" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 392px;">14</div><div id="_r_id_-15" role="option" aria-selected="false" data-wheel-row="" data-label="15" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 420px;">15</div><div id="_r_id_-16" role="option" aria-selected="false" data-wheel-row="" data-label="16" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 448px;">16</div><div id="_r_id_-17" role="option" aria-selected="false" data-wheel-row="" data-label="17" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 476px;">17</div><div id="_r_id_-18" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="18" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 504px;">18</div><div id="_r_id_-19" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="19" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 532px;">19</div><div id="_r_id_-20" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="20" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 560px;">20</div><div id="_r_id_-21" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="21" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 588px;">21</div><div id="_r_id_-22" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="22" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 616px;">22</div><div id="_r_id_-23" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="23" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 644px;">23</div></div></div></div>"`;+exports[`PickerWheel — markup > keeps the touch column’s markup 1`] = `"<div role="listbox" aria-label="Hour" aria-activedescendant="_r_id_-10" tabindex="0" data-wheel="" class="PickerWheel__styles.column x1n2onr6 x1cqoux5 xeuugli xm8gem xb3r6kr x1a2a7pz x1i10hfl focusOutline__focusOutlineStyles.focusVisible x1k57tk5 x1vidyx5 x1t137rt x1jhp3zv xx47ajj x1wfwxd8 x1vwwbsn" data-astryx-touch-action="pan-x pinch-zoom"><div data-wheel-fade="" class="PickerWheel__styles.fade x10l6tqk x10a8y8t x47corl xsshixw"><div aria-hidden="true" class="PickerWheel__styles.band x10l6tqk x17y0mx6 x7rbydg x6hpsvf xh6dtrn x17x4s8c x47corl"></div><div data-wheel-strip="" class="PickerWheel__styles.strip x10l6tqk x17y0mx6 x7rbydg x47corl" style="translate: 0px -280px;"><div id="_r_id_-0" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="00" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 0px;">00</div><div id="_r_id_-1" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="01" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 28px;">01</div><div id="_r_id_-2" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="02" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 56px;">02</div><div id="_r_id_-3" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="03" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 84px;">03</div><div id="_r_id_-4" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="04" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 112px;">04</div><div id="_r_id_-5" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="05" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 140px;">05</div><div id="_r_id_-6" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="06" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 168px;">06</div><div id="_r_id_-7" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="07" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 196px;">07</div><div id="_r_id_-8" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="08" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 224px;">08</div><div id="_r_id_-9" role="option" aria-selected="false" data-wheel-row="" data-label="09" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 252px;">09</div><div id="_r_id_-10" role="option" aria-selected="true" data-wheel-row="" data-label="10" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowActive xjse4m1 x2mo6ok" style="--x-insetBlockStart: 280px; color: var(--color-text-accent); font-weight: var(--font-weight-semibold);">10</div><div id="_r_id_-11" role="option" aria-selected="false" data-wheel-row="" data-label="11" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 308px;">11</div><div id="_r_id_-12" role="option" aria-selected="false" data-wheel-row="" data-label="12" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 336px;">12</div><div id="_r_id_-13" role="option" aria-selected="false" data-wheel-row="" data-label="13" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 364px;">13</div><div id="_r_id_-14" role="option" aria-selected="false" data-wheel-row="" data-label="14" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 392px;">14</div><div id="_r_id_-15" role="option" aria-selected="false" data-wheel-row="" data-label="15" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 420px;">15</div><div id="_r_id_-16" role="option" aria-selected="false" data-wheel-row="" data-label="16" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 448px;">16</div><div id="_r_id_-17" role="option" aria-selected="false" data-wheel-row="" data-label="17" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla x1tgivj0 xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7" style="--x-insetBlockStart: 476px;">17</div><div id="_r_id_-18" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="18" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 504px;">18</div><div id="_r_id_-19" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="19" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 532px;">19</div><div id="_r_id_-20" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="20" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 560px;">20</div><div id="_r_id_-21" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="21" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 588px;">21</div><div id="_r_id_-22" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="22" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 616px;">22</div><div id="_r_id_-23" role="option" aria-selected="false" aria-disabled="true" data-wheel-row="" data-label="23" class="PickerWheel__styles.row x10l6tqk x17y0mx6 x6hpsvf x78zum5 x6s0dn4 xl56j7k xf314gf x9f619 x18juvz8 x1sodnla xuxw1ft xb3r6kr xlyipyv x87ps6o PickerWheel__styles.rowAt x5mnzd7 PickerWheel__styles.rowDisabled xnbbluu" style="--x-insetBlockStart: 644px;">23</div></div></div></div>"`;diff --git a/packages/core/src/DateInput/__tests__/PickerWheelContrast.a11y.chromium.spec.ts b/packages/core/src/DateInput/__tests__/PickerWheelContrast.a11y.chromium.spec.tsnew file mode 100644index 0000000000..5f089e5688--- /dev/null+++ b/packages/core/src/DateInput/__tests__/PickerWheelContrast.a11y.chromium.spec.ts@@ -0,0 +1,151 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+// @pr-a11y scope ^packages/core/src/theme/ ^packages/themes/ ^apps/storybook/stories/WheelProofs++/**+ * @file PickerWheelContrast.a11y.chromium.spec.ts+ * @input The built `Core/Wheel` touch-minutes story (the touch column) in+ * every shipped theme, light and dark, read as screenshots+ * @output Chromium proof that every row in view of the touch column meets+ * WCAG AA contrast against its background, as the page draws it+ * @position The column fades its rows with a mask, which axe cannot see. So+ * the spec reads pixels: each row's strongest text pixel against the row's+ * background.+ */++import {expect, test, type Page} from '@astryxdesign/a11y-spec/playwright';+// @ts-expect-error -- pngjs ships no declarations; runtime support is pinned.+import {PNG} from 'pngjs';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';++let storybook: StaticServer;+test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});+test.afterAll(async () => {+ await storybook?.close();+});++// Two device pixels per CSS pixel, so each glyph stroke covers whole pixels.+test.use({deviceScaleFactor: 2});++const STORY = 'core-wheel--touch-minutes';+const SHIPPED_THEMES = [+ 'butter',+ 'chocolate',+ 'gothic',+ 'matcha',+ 'neutral',+ 'stone',+ 'y2k',+];+const MODES = ['light', 'dark'];++type Rgb = [number, number, number];++function luminance([r, g, b]: Rgb): number {+ const linear = (v: number) => {+ const c = v / 255;+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;+ };+ return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);+}++function contrast(a: Rgb, b: Rgb): number {+ const [high, low] = [luminance(a), luminance(b)].sort((x, y) => y - x);+ return (high + 0.05) / (low + 0.05);+}++/** The boxes of the rows whose centres sit inside the column, in CSS px. */+async function rowsInView(page: Page) {+ return page.evaluate(() => {+ const listbox = document.querySelector('[role="listbox"]');+ if (listbox == null) {+ return [];+ }+ const view = listbox.getBoundingClientRect();+ return [...listbox.querySelectorAll<HTMLElement>('[role="option"]')]+ .map(row => {+ const box = row.getBoundingClientRect();+ return {+ label: row.dataset.label ?? row.textContent ?? '',+ x: box.x,+ y: box.y,+ width: box.width,+ height: box.height,+ };+ })+ .filter(box => {+ const middle = box.y + box.height / 2;+ return middle > view.top && middle < view.bottom;+ });+ });+}++/**+ * Each row in view below WCAG AA (4.5:1). A row's background is its most+ * common pixel. Its text is the pixel that differs most from that background,+ * which is a fully covered stroke at two device pixels per CSS pixel.+ */+async function rowsBelowAA(page: Page): Promise<string[]> {+ const rows = await rowsInView(page);+ const scale = 2;+ const failures: string[] = [];+ for (const row of rows) {+ const shot = await page.screenshot({+ animations: 'disabled',+ clip: {x: row.x, y: row.y, width: row.width, height: row.height},+ });+ const png = PNG.sync.read(shot);+ const counts = new Map<number, number>();+ const pixels: Rgb[] = [];+ for (let i = 0; i < png.data.length; i += 4) {+ const pixel: Rgb = [png.data[i], png.data[i + 1], png.data[i + 2]];+ pixels.push(pixel);+ const key = (pixel[0] << 16) | (pixel[1] << 8) | pixel[2];+ counts.set(key, (counts.get(key) ?? 0) + 1);+ }+ const [key] = [...counts].reduce((best, entry) =>+ entry[1] > best[1] ? entry : best,+ );+ const background: Rgb = [(key >> 16) & 255, (key >> 8) & 255, key & 255];+ const ratio = Math.max(...pixels.map(pixel => contrast(pixel, background)));+ if (pixels.length < row.width * row.height * scale * scale * 0.9) {+ failures.push(`row ${row.label}: screenshot too small to read`);+ } else if (ratio < 4.5) {+ failures.push(`row ${row.label}: ${ratio.toFixed(2)}:1`);+ }+ }+ return failures;+}++for (const theme of SHIPPED_THEMES) {+ test(`the touch column's rows meet AA contrast in ${theme}, light and dark`, async ({+ page,+ }) => {+ const failures: string[] = [];+ for (const mode of MODES) {+ await page.goto(+ `${storybook.origin}/iframe.html?id=${STORY}&viewMode=story&globals=astryxTheme:${theme};colorMode:${mode}`,+ );+ await expect(page.getByRole('option').first()).toBeVisible();+ await page.evaluate(async () => {+ await document.fonts.ready;+ await new Promise(resolve =>+ requestAnimationFrame(() => requestAnimationFrame(resolve)),+ );+ });+ // At 00 the column shows rows 00 to 04 below the band, and the claim+ // rests on the outer ones.+ expect((await rowsInView(page)).length).toBeGreaterThanOrEqual(5);+ const found = await rowsBelowAA(page);+ failures.push(...found.map(failure => `${mode}: ${failure}`));+ }+ expect(failures).toEqual([]);+ });+}