An open source design system that's fully customizable and agent ready
TypeScript
fix(DateInput): the scrolling picker column's rows keep AA contrast; the depth fade uses theme text colours (#9853)
Christopher Chedeau42ccd7cfaa96
diff --git a/.changeset/wheel-rows-aa-contrast.md b/.changeset/wheel-rows-aa-contrast.mdnew file mode 100644index 0000000000..db0fb951e6--- /dev/null+++ b/.changeset/wheel-rows-aa-contrast.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] DateInput: with a mouse, the rows of the bottom-sheet picker's columns meet WCAG AA contrast at every scroll position; enabled rows fade by the theme's text colors instead of opacity.++@vjeuxdiff --git a/apps/storybook/stories/WheelProofs.stories.tsx b/apps/storybook/stories/WheelProofs.stories.tsxindex 2137757018..7fc4d191ed 100644--- a/apps/storybook/stories/WheelProofs.stories.tsx+++ b/apps/storybook/stories/WheelProofs.stories.tsx@@ -23,6 +23,13 @@ const MINUTES = Array.from({length: 60}, (_, minute) => ({label: String(minute).padStart(2, '0'),}));+/**+ * The readout takes the theme's text colour on the theme's surface. A bare+ * field keeps the browser's white fill under the theme's text colour, which a+ * dark theme makes unreadable.+ */+const READOUT_STYLE = {color: 'inherit', backgroundColor: 'transparent'};+const meta = {title: 'Core/Wheel',tags: ['no-visual', '!autodocs'],@@ -44,6 +51,7 @@ export const Minutes: Story = {<inputaria-label="Committed minute"readOnly+ style={READOUT_STYLE}value={String(minute).padStart(2, '0')}/><Wheel@@ -70,6 +78,7 @@ export const TouchMinutes: Story = {<inputaria-label="Committed minute"readOnly+ style={READOUT_STYLE}value={String(minute).padStart(2, '0')}/><PickerWheeldiff --git a/packages/core/src/DateInput/PickerWheel.tsx b/packages/core/src/DateInput/PickerWheel.tsxindex 8deee68ef9..2650c3790a 100644--- a/packages/core/src/DateInput/PickerWheel.tsx+++ b/packages/core/src/DateInput/PickerWheel.tsx@@ -76,10 +76,8 @@ const styles = stylex.create({outline: 'none',WebkitTapHighlightColor: 'transparent',},- // The rows fade toward the column's edges, from the scrolling column's 0.3- // to fully opaque at the band and back. The scrolling column fades them the- // same way under reduced motion. A static mask: nothing paints it again as- // the strip moves. It sits inside the column, so it never clips the+ // The rows fade toward the column's edges. A static mask: nothing paints it+ // again as the strip moves. It sits inside the column, so it never clips the// column's focus ring.fade: {position: 'absolute',diff --git a/packages/core/src/DateInput/Wheel.tsx b/packages/core/src/DateInput/Wheel.tsxindex 29cb1e5848..c6eaf43a0e 100644--- a/packages/core/src/DateInput/Wheel.tsx+++ b/packages/core/src/DateInput/Wheel.tsx@@ -71,23 +71,38 @@ const ITEM_BLOCK_SIZE = dateInputTouchSizes.wheelItemSize;* at the top — which is what a `view()` timeline over the `cover` range means,* and why this reads as a cylinder rotating under the finger.*/-const falloff = stylex.keyframes({+const tip = stylex.keyframes({+ '0%': {transform: 'rotateX(52deg) scale(0.86)'},+ '50%': {transform: 'rotateX(0deg) scale(1)'},+ '100%': {transform: 'rotateX(-52deg) scale(0.86)'},+});++/**+ * Colour keeps every row at WCAG AA, which an opacity fade does not. The ends+ * stop halfway to the secondary text colour, because that colour alone falls+ * below AA in two shipped themes.+ */+const fade = stylex.keyframes({'0%': {- opacity: 0.3,- transform: 'rotateX(52deg) scale(0.86)',- },- '50%': {- opacity: 1,- transform: 'rotateX(0deg) scale(1)',+ color: `color-mix(in oklab, ${colorVars['--color-text-primary']}, ${colorVars['--color-text-secondary']})`,},+ '50%': {color: colorVars['--color-text-primary']},'100%': {- opacity: 0.3,- transform: 'rotateX(-52deg) scale(0.86)',+ color: `color-mix(in oklab, ${colorVars['--color-text-primary']}, ${colorVars['--color-text-secondary']})`,},});-/** Motion-free equivalent: the depth cue survives as opacity alone. */-const fadeOnly = stylex.keyframes({+/**+ * A disabled row keeps its disabled colour and fades by opacity instead: WCAG+ * 1.4.3 exempts inactive components from the contrast minimum.+ */+const tipAndDim = stylex.keyframes({+ '0%': {opacity: 0.3, transform: 'rotateX(52deg) scale(0.86)'},+ '50%': {opacity: 1, transform: 'rotateX(0deg) scale(1)'},+ '100%': {opacity: 0.3, transform: 'rotateX(-52deg) scale(0.86)'},+});++const dim = stylex.keyframes({'0%': {opacity: 0.3},'50%': {opacity: 1},'100%': {opacity: 0.3},@@ -115,7 +130,7 @@ const styles = stylex.create({overscrollBehavior: 'contain',// Room for row 0 and row n-1 to reach the centre.paddingBlock: dateInputTouchGeometry.wheelEdgePadding,- // Gives the rotateX falloff somewhere to recede to.+ // Gives the rotateX tip somewhere to recede to.perspective: '520px',transformStyle: 'preserve-3d',scrollbarWidth: 'none',@@ -144,7 +159,7 @@ const styles = stylex.create({whiteSpace: 'nowrap',// NO `overflow: hidden` here. It would make the row itself a scroll// container, and `view()` binds to the subject's nearest ancestor scroll- // container — the falloff would measure the row against itself and sit+ // container — the tip would measure the row against itself and sit// frozen at 50% forever. Clipping belongs on the inner element.cursor: {default: 'pointer',@@ -155,7 +170,7 @@ const styles = stylex.create({transitionDuration: durationVars['--duration-fast'],},/**- * The falloff rides an inner element, never the row itself.+ * The tip rides an inner element, never the row itself.** A snap area is the element's TRANSFORMED border box, so animating the row* would move the very positions the scroller is snapping to — the wheel@@ -171,15 +186,14 @@ const styles = stylex.create({overflow: 'hidden',textOverflow: 'ellipsis',// The wheel look. Held behind @supports so browsers without scroll-driven- // animations get a plain, fully legible list instead of these keyframes- // playing themselves out once on the document timeline. Under reduced- // motion the same timeline drives opacity only — the depth cue survives,- // the tipping does not.+ // animations get a plain list instead of these keyframes playing+ // themselves out once on the document timeline. Under reduced motion, the+ // colour fade on the row keeps the depth cue.animationName: {default: null,'@supports (animation-timeline: view())': {- default: falloff,- '@media (prefers-reduced-motion: reduce)': fadeOnly,+ default: tip,+ '@media (prefers-reduced-motion: reduce)': 'none',},},animationTimeline: 'view(y)',@@ -189,6 +203,31 @@ const styles = stylex.create({animationTimingFunction: 'linear',backfaceVisibility: 'hidden',},+ itemInnerDisabled: {+ animationName: {+ default: null,+ '@supports (animation-timeline: view())': {+ default: tipAndDim,+ '@media (prefers-reduced-motion: reduce)': dim,+ },+ },+ },+ /**+ * The colour fade, on the row and not the tipped inner element: colour does+ * not move a snap area. An animated colour outranks the selected and+ * disabled colours, so those rows do not take this fade.+ */+ itemFade: {+ animationName: {+ default: null,+ '@supports (animation-timeline: view())': fade,+ },+ animationTimeline: 'view(y)',+ animationRange: 'cover 0% cover 100%',+ animationFillMode: 'both',+ animationDuration: 'auto',+ animationTimingFunction: 'linear',+ },itemActive: {color: colorVars['--color-text-accent'],fontWeight: fontWeightVars['--font-weight-semibold'],@@ -568,10 +607,17 @@ export function ScrollWheel({{...optionProps(option, index)}{...stylex.props(styles.item,+ index !== activeIndex && !option.isDisabled && styles.itemFade,index === activeIndex && styles.itemActive,option.isDisabled && styles.itemDisabled,)}>- <span {...stylex.props(styles.itemInner)}>{option.label}</span>+ <span+ {...stylex.props(+ styles.itemInner,+ option.isDisabled && styles.itemInnerDisabled,+ )}>+ {option.label}+ </span></div>))}</div>diff --git a/packages/core/src/DateInput/__snapshots__/Wheel.test.tsx.snap b/packages/core/src/DateInput/__snapshots__/Wheel.test.tsx.snapindex 7363fd6e39..89de44d369 100644--- a/packages/core/src/DateInput/__snapshots__/Wheel.test.tsx.snap+++ b/packages/core/src/DateInput/__snapshots__/Wheel.test.tsx.snap@@ -1,3 +1,3 @@// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html-exports[`Wheel — markup > keeps today’s column’s markup 1`] = `"<div class="Wheel__styles.column x1n2onr6 x1cqoux5 xeuugli"><div aria-hidden="true" class="Wheel__styles.band x10l6tqk x17y0mx6 x7rbydg x6hpsvf xh6dtrn x17x4s8c x47corl"></div><div role="listbox" aria-label="Hour" aria-activedescendant="_r_id_-10" tabindex="0" class="Wheel__styles.scroller xm8gem x9f619 x1odjw0f x6ikm8r x168l2et xish69e x1uameg1 x201tam x1oyok0e x1rohswg x1a2a7pz xge0x1e focusOutline__focusOutlineStyles.focusVisible x1k57tk5 x1vidyx5 x1t137rt x1jhp3zv xx47ajj x1wfwxd8 x1vwwbsn"><div id="_r_id_-0" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">00</span></div><div id="_r_id_-1" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">01</span></div><div id="_r_id_-2" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">02</span></div><div id="_r_id_-3" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">03</span></div><div id="_r_id_-4" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">04</span></div><div id="_r_id_-5" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">05</span></div><div id="_r_id_-6" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">06</span></div><div id="_r_id_-7" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">07</span></div><div id="_r_id_-8" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">08</span></div><div id="_r_id_-9" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">09</span></div><div id="_r_id_-10" role="option" aria-selected="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemActive xjse4m1 x2mo6ok"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">10</span></div><div id="_r_id_-11" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">11</span></div><div id="_r_id_-12" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">12</span></div><div id="_r_id_-13" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">13</span></div><div id="_r_id_-14" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">14</span></div><div id="_r_id_-15" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">15</span></div><div id="_r_id_-16" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">16</span></div><div id="_r_id_-17" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">17</span></div><div id="_r_id_-18" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">18</span></div><div id="_r_id_-19" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">19</span></div><div id="_r_id_-20" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">20</span></div><div id="_r_id_-21" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">21</span></div><div id="_r_id_-22" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">22</span></div><div id="_r_id_-23" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">23</span></div></div></div>"`;+exports[`Wheel — markup > keeps today’s column’s markup 1`] = `"<div class="Wheel__styles.column x1n2onr6 x1cqoux5 xeuugli"><div aria-hidden="true" class="Wheel__styles.band x10l6tqk x17y0mx6 x7rbydg x6hpsvf xh6dtrn x17x4s8c x47corl"></div><div role="listbox" aria-label="Hour" aria-activedescendant="_r_id_-10" tabindex="0" class="Wheel__styles.scroller xm8gem x9f619 x1odjw0f x6ikm8r x168l2et xish69e x1uameg1 x201tam x1oyok0e x1rohswg x1a2a7pz xge0x1e focusOutline__focusOutlineStyles.focusVisible x1k57tk5 x1vidyx5 x1t137rt x1jhp3zv xx47ajj x1wfwxd8 x1vwwbsn"><div id="_r_id_-0" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">00</span></div><div id="_r_id_-1" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">01</span></div><div id="_r_id_-2" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">02</span></div><div id="_r_id_-3" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">03</span></div><div id="_r_id_-4" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">04</span></div><div id="_r_id_-5" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">05</span></div><div id="_r_id_-6" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">06</span></div><div id="_r_id_-7" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">07</span></div><div id="_r_id_-8" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">08</span></div><div id="_r_id_-9" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">09</span></div><div id="_r_id_-10" role="option" aria-selected="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemActive xjse4m1 x2mo6ok"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">10</span></div><div id="_r_id_-11" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">11</span></div><div id="_r_id_-12" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">12</span></div><div id="_r_id_-13" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">13</span></div><div id="_r_id_-14" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">14</span></div><div id="_r_id_-15" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">15</span></div><div id="_r_id_-16" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">16</span></div><div id="_r_id_-17" role="option" aria-selected="false" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemFade xssvwzl x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1trhrh1 x1pljy2o x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z">17</span></div><div id="_r_id_-18" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">18</span></div><div id="_r_id_-19" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">19</span></div><div id="_r_id_-20" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">20</span></div><div id="_r_id_-21" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">21</span></div><div id="_r_id_-22" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">22</span></div><div id="_r_id_-23" role="option" aria-selected="false" aria-disabled="true" class="Wheel__styles.item x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 Wheel__styles.itemDisabled xnbbluu xt0e3qv"><span class="Wheel__styles.itemInner x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z Wheel__styles.itemInnerDisabled x1iu2jvn xk3h8ob">23</span></div></div></div>"`;diff --git a/packages/core/src/DateInput/__tests__/WheelContrast.a11y.chromium.spec.ts b/packages/core/src/DateInput/__tests__/WheelContrast.a11y.chromium.spec.tsnew file mode 100644index 0000000000..c9daccf27f--- /dev/null+++ b/packages/core/src/DateInput/__tests__/WheelContrast.a11y.chromium.spec.ts@@ -0,0 +1,221 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+// @pr-a11y scope ^packages/core/src/theme/ ^packages/themes/ ^apps/storybook/stories/WheelProofs++/**+ * @file WheelContrast.a11y.chromium.spec.ts+ * @input The built `Core/Wheel` minutes story (the scrolling column) in every+ * shipped theme, light and dark, and axe's color-contrast rule+ * @output Chromium proof that every row of the scrolling column and its+ * readout meet WCAG AA contrast, at rest and in the still frame the release+ * audit scans+ * @position The release audit scans one theme in a still frame. This spec+ * holds the same rule in each shipped theme when the column or a theme+ * changes.+ */++import AxeBuilder from '@axe-core/playwright';+import {expect, test, type Browser, type Page} from '@playwright/test';+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();+});++const STORY = 'core-wheel--minutes';+const SHIPPED_THEMES = [+ 'butter',+ 'chocolate',+ 'gothic',+ 'matcha',+ 'neutral',+ 'stone',+ 'y2k',+];+const MODES = ['light', 'dark'];++// The release audit's still frame (.github/scripts/accessibility-audit.js):+// every animation and transition is held at its end.+const STILL_FRAME = `+*, *::before, *::after {+ animation-duration: 0s !important;+ animation-delay: 0s !important;+ animation-iteration-count: 1 !important;+ transition-duration: 0s !important;+ transition-delay: 0s !important;+}+`;++// Tipped rows overlap. The tip does not change a colour, so flat rows give+// each row its own box.+const FLAT_ROWS = '[role="option"] > span { transform: none !important; }';++/**+ * The rows in view that fall below WCAG AA (4.5:1). The measure uses what the+ * page draws. The text colour takes the opacity of the row and its ancestors.+ * Every background behind the row counts, the band included. Inside the+ * scroller, axe reports these backgrounds as unknown, so the spec measures.+ */+async function rowsBelowAA(page: Page): Promise<string[]> {+ return page.evaluate(() => {+ const canvas = document.createElement('canvas').getContext('2d', {+ willReadFrequently: true,+ })!;+ type Rgba = [number, number, number, number];+ const rgba = (color: string): Rgba => {+ canvas.clearRect(0, 0, 1, 1);+ canvas.fillStyle = color;+ canvas.fillRect(0, 0, 1, 1);+ const [r, g, b, a] = canvas.getImageData(0, 0, 1, 1).data;+ return [r, g, b, a / 255];+ };+ const over = (top: Rgba, under: Rgba): Rgba => {+ const a = top[3] + under[3] * (1 - top[3]);+ const mix = (i: number) =>+ a === 0+ ? 0+ : (top[i] * top[3] + under[i] * under[3] * (1 - top[3])) / a;+ return [mix(0), mix(1), mix(2), a];+ };+ const luminance = ([r, g, b]: Rgba) => {+ 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);+ };+ const failures: string[] = [];+ for (const listbox of document.querySelectorAll('[role="listbox"]')) {+ const view = listbox.getBoundingClientRect();+ const band = listbox.parentElement?.querySelector(+ ':scope > [aria-hidden="true"]',+ );+ for (const row of listbox.querySelectorAll<HTMLElement>(+ '[role="option"]',+ )) {+ const text = row.querySelector('span') ?? row;+ const box = text.getBoundingClientRect();+ const middle = box.top + box.height / 2;+ if (middle < view.top || middle > view.bottom) {+ continue;+ }+ let opacity = 1;+ const ancestors: Element[] = [];+ for (+ let node: Element | null = text;+ node != null;+ node = node.parentElement+ ) {+ opacity *= Number(getComputedStyle(node).opacity);+ ancestors.unshift(node);+ }+ let background: Rgba = [255, 255, 255, 1];+ for (const node of ancestors) {+ background = over(+ rgba(getComputedStyle(node).backgroundColor),+ background,+ );+ }+ if (band != null) {+ const plate = band.getBoundingClientRect();+ if (middle > plate.top && middle < plate.bottom) {+ background = over(+ rgba(getComputedStyle(band).backgroundColor),+ background,+ );+ }+ }+ const ink = rgba(getComputedStyle(text).color);+ const drawn = over(+ [ink[0], ink[1], ink[2], ink[3] * opacity],+ background,+ );+ const [high, low] = [luminance(drawn), luminance(background)].sort(+ (a, b) => b - a,+ );+ const ratio = (high + 0.05) / (low + 0.05);+ if (ratio < 4.5) {+ failures.push(+ `row ${row.dataset.label ?? row.textContent}: ${ratio.toFixed(2)}:1`,+ );+ }+ }+ }+ return failures;+ });+}++/** The color-contrast failures of one story, one way it is shown. */+async function contrastFailures(+ browser: Browser,+ url: string,+ isStill: boolean,+): Promise<string[]> {+ const context = await browser.newContext();+ try {+ const page = await context.newPage();+ if (isStill) {+ await page.addInitScript(css => {+ const add = () => {+ const style = document.createElement('style');+ style.textContent = css;+ document.head.append(style);+ };+ if (document.head != null) {+ add();+ } else {+ document.addEventListener('DOMContentLoaded', add);+ }+ }, STILL_FRAME);+ }+ await page.goto(url);+ await expect(page.getByRole('option').first()).toBeVisible();+ await page.addStyleTag({content: FLAT_ROWS});+ await page.evaluate(async () => {+ await document.fonts.ready;+ await new Promise(resolve =>+ requestAnimationFrame(() => requestAnimationFrame(resolve)),+ );+ });+ const {violations} = await new AxeBuilder({page})+ .withRules(['color-contrast'])+ .analyze();+ return [+ ...violations.flatMap(violation =>+ violation.nodes.map(node => {+ const data = (node.any[0]?.data ?? {}) as Record<string, unknown>;+ return `${node.target.join(' ')}: ${String(data.fgColor)} on ${String(data.bgColor)}, ${String(data.contrastRatio)}:1`;+ }),+ ),+ ...(await rowsBelowAA(page)),+ ];+ } finally {+ await context.close();+ }+}++for (const theme of SHIPPED_THEMES) {+ test(`the scrolling column meets AA contrast in ${theme}, light and dark, at rest and still`, async ({+ browser,+ }) => {+ const failures: string[] = [];+ for (const mode of MODES) {+ const url = `${storybook.origin}/iframe.html?id=${STORY}&viewMode=story&globals=astryxTheme:${theme};colorMode:${mode}`;+ for (const isStill of [false, true]) {+ const found = await contrastFailures(browser, url, isStill);+ const frame = isStill ? 'still' : 'at rest';+ failures.push(...found.map(failure => `${mode}, ${frame}: ${failure}`));+ }+ }+ expect(failures).toEqual([]);+ });+}diff --git a/packages/core/src/DateInput/__tests__/WheelRest.a11y.chromium.spec.ts b/packages/core/src/DateInput/__tests__/WheelRest.a11y.chromium.spec.tsindex 8f2b96dda4..901d9e330d 100644--- a/packages/core/src/DateInput/__tests__/WheelRest.a11y.chromium.spec.ts+++ b/packages/core/src/DateInput/__tests__/WheelRest.a11y.chromium.spec.ts@@ -3,8 +3,8 @@/*** @file WheelRest.a11y.chromium.spec.ts- * @input The built TimeInput bottom-sheet story with bounds; real Chromium- * touch input (CDP) on a phone profile, and a mouse on a desktop one+ * @input The built TimeInput bottom-sheet story with bounds and the Wheel+ * story; real touch input (CDP) on a phone profile, a mouse on a desktop one* @output Browser evidence that a wheel dragged onto a row outside the bounds* comes to rest on the nearest row inside them and commits it, on the touch* column under a finger and on today's column under a mouse; that a@@ -501,19 +501,53 @@ test.describe('under a mouse', () => {await expect(field).toHaveValue('11:00 AM');});- test('under Reduce Motion, the rows fade toward the edges without tipping', async ({+ test('under Reduce Motion, a disabled row fades toward the edges without tipping', async ({page,}) => {await page.emulateMedia({reducedMotion: 'reduce'});const {hours} = await openHourWheelWithMouse(page);await expectFinePointer(page);- // Two rows above the band (8 AM): dimmed, and flat.- const label = hours.locator('[role="option"]').nth(8).locator('span');- const {opacity, transform} = await label.evaluate(el => {+ // Two rows above the band (8 AM), outside the bounds: dimmed, and flat.+ const row = hours.locator('[role="option"]').nth(7);+ await expect(row).toHaveText('8');+ await expect(row).toHaveAttribute('aria-disabled', 'true');+ const {opacity, transform} = await row.locator('span').evaluate(el => {const style = getComputedStyle(el);return {opacity: Number(style.opacity), transform: style.transform};});expect(opacity).toBeLessThan(0.95);expect(transform).toBe('none');});++ test('under Reduce Motion, the enabled rows fade toward the edges in colour without tipping', async ({+ page,+ }) => {+ await page.emulateMedia({reducedMotion: 'reduce'});+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-wheel--minutes&viewMode=story`,+ );+ await expectFinePointer(page);+ const rows = page+ .getByRole('listbox', {name: 'Minute'})+ .locator('[role="option"] > span');+ await expect(rows.first()).toBeVisible();+ const drawn = async (index: number) =>+ rows.nth(index).evaluate(el => {+ const style = getComputedStyle(el);+ return {+ color: style.color,+ opacity: Number(style.opacity),+ transform: style.transform,+ };+ });+ // 00 sits under the band, and 01 and 02 sit one and two rows away. Both+ // are flat and opaque, and 02 is further along the colour fade.+ const near = await drawn(1);+ const far = await drawn(2);+ for (const row of [near, far]) {+ expect(row.transform).toBe('none');+ expect(row.opacity).toBe(1);+ }+ expect(far.color).not.toBe(near.color);+ });});