From e9b716fa63be4b5fa399855dd8682067dfa91018 Mon Sep 17 00:00:00 2001 From: Wanjohi Date: Fri, 2 Oct 2026 05:55:44 +0300 Subject: [PATCH] style(auth): shake the field when its answer was wrong Every error arrives as a new page, so an animation that runs on load runs exactly when one does, with no script to trigger it. It plays once, only on a form showing an error alert, and not at all for anyone who has asked for reduced motion. --- packages/auth/src/ui/css.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/auth/src/ui/css.ts b/packages/auth/src/ui/css.ts index d72dba46..6ef407f4 100644 --- a/packages/auth/src/ui/css.ts +++ b/packages/auth/src/ui/css.ts @@ -486,6 +486,20 @@ form:has([data-component='input']:invalid) [data-component='button']:hover { font-variant-numeric: tabular-nums; } +/* A wrong answer shakes the field it came from, once. Every error is a new + page, so an animation that runs on load runs exactly when one arrives — + no script needed to trigger it. */ +@keyframes shake { + 0%, 100% { translate: 0; } + 15%, 55% { translate: -0.5rem; } + 35%, 75% { translate: 0.5rem; } + 90% { translate: -0.2rem; } +} + +form:has([data-component='form-alert'][data-color='danger']) [data-component='input'] { + animation: shake 400ms ease-in-out; +} + [data-component='input'][data-variant='code']::placeholder { letter-spacing: normal; font-size: 1rem; @@ -521,5 +535,9 @@ form:has([data-component='input']:invalid) [data-component='button']:hover { [data-component='button']:hover { scale: 1; } + + form:has([data-component='form-alert'][data-color='danger']) [data-component='input'] { + animation: none; + } } `;