mirror of
https://github.com/nestriness/nestri.git
synced 2026-11-17 20:51:44 +02:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user