Skip to content

fix(a11y): respect reduced motion in TiltCard - #14

Merged
LangerSword merged 3 commits into
mainfrom
fix/tilt-reduced-motion
Nov 25, 2026
Merged

LangerSword merged 3 commits into
mainfrom
fix/tilt-reduced-motion

Conversation

@LangerSword

Copy link
Copy Markdown
Owner

Fixes #6.

TiltCard wrote style.transform and glare coordinates on every pointer move with no motion-preference check. On reduced motion, card tilt and glare now stay static.

Changes:

  • Track prefers-reduced-motion once per mount with a media-query listener.
  • Short-circuit pointer updates while reduced motion is active.
  • Clear transform, transition and glare position when the preference turns on.
  • Add CSS guards so hydration or inline styles cannot restore the tilt.
  • Add a Vitest regression test for both reduced-motion and normal paths.

Verification:

  • npm test — 40 tests pass, including the new regression.
  • npx tsc --noEmit — pass.
  • npm run build — pass.
  • Regression test fails when the reduced-motion guard is removed.

The repo has no Playwright dependency, so the test exercises the exported handler contract directly instead of emulateMedia. The behaviour is the same: no transform or glare write when reduced motion matches.

Not addressed: the pre-existing prefer-const lint error in WarmOnView.tsx; it is unrelated to this issue and CI does not run lint.

@github-actions

Copy link
Copy Markdown

Verdict

READY

Findings

No findings.

Tests

The added test proves the pure applyTiltStyle short-circuit and the normal-path math, but it never renders TiltCard or mocks matchMedia; the listener setup, state-to-handler wiring, imperative clear Effect, and CSS !important guards are unverified, so a broken integration could still pass.

@github-actions

Copy link
Copy Markdown

Verdict: ship, medium confidence. The merge call stays with the maintainer.

Findings

No findings.

Open questions

  • app/globals.css, hunk at line 265: the two new rules sit beside reduced-motion overrides. The hunk header shows @@ -265,6 +265,8 @@ body { and does not show the enclosing at-rule. If the rules are not inside @media (prefers-reduced-motion: reduce), transform: perspective(1000px) !important and transition: none !important disable tilt for every user and override all inline writes. The surrounding lines suggest the reduced-motion block, but I cannot verify the at-rule from the diff.
  • components/TiltCard.tsx:33: watchReducedMotion calls media.addEventListener and media.removeEventListener. Safari 13 and earlier expose only addListener and removeListener on MediaQueryList. If those browsers are in scope, the mount effect at lines 47-52 throws and tracking never starts. I cannot verify the supported browser matrix from the diff. Cheapest fix if needed: feature-detect addEventListener and fall back to addListener with a handler that reads media.matches.

Test gaps

  • The tests call only the two exported helpers. No test covers the effect that clears transform, transition and glare when the preference changes (components/TiltCard.tsx:55-66). Add a render-level test: mount TiltCard, flip media.matches, assert the element resets.
  • No test covers the reduced-motion onLeave guard at components/TiltCard.tsx:76.
  • The CSS guards have no test. The PR body states the repo has no Playwright. Treat the CSS as unverified, not as passing.

Evidence boundary: I reviewed the diff only. I did not run npm test, npx tsc --noEmit, or npm run build. The verification claims in the PR body are untrusted context.

@github-actions

Copy link
Copy Markdown

Rook / automated review

Verdict

ship (high confidence). Merge call stays with the maintainer.

Findings

P3|components/TiltCard.tsx:33|low|watchReducedMotion calls media.addEventListener("change", update). MediaQueryList.addEventListener needs Safari 14+. The old code had no media listener, so this raises the browser floor. If Safari 13 or older is in scope, add an addListener/removeListener fallback. I cannot verify the support matrix from the diff.

Test gaps

I did not run npm test, npx tsc --noEmit, or npm run build. The pass claims in the PR body are unverified from the diff.

No test covers the effect at components/TiltCard.tsx:55 that clears transform, transition, and glare when the preference flips on at runtime. The three tests exercise only the exported pure helpers.

Evidence boundary

The handler guard, the CSS !important overrides, and the helper tests are present in the diff. I verified the two test expectations by hand: px = 0.95 gives --mx "95.0%", and py = 0.9 gives --my "90.0%". I did not render the component or run a media query, so the DOM-level clearing and the CSS guard are unchecked at runtime.

@LangerSword
LangerSword merged commit ddd8917 into main Nov 25, 2026
3 checks passed
@LangerSword
LangerSword deleted the fix/tilt-reduced-motion branch November 25, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect prefers-reduced-motion in TiltCard

1 participant