Skip to content

Commit 47e52ee

Browse files
committed
add a little shaker, when login failed
1 parent 7d6c79f commit 47e52ee

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

client/src/components/loginprompt.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
type="warning"
2424
border="start"
2525
class="mb-5"
26+
:class="{ 'shaking': errorshake }"
2627
>Wrong username or password!
2728
</v-alert>
2829
<form v-on:submit="login">
@@ -93,6 +94,7 @@ export default defineComponent({
9394
name: "Login",
9495
data: () => ({
9596
error: false,
97+
errorshake: false,
9698
authMethods : {
9799
"local": false,
98100
"github": false,
@@ -135,6 +137,10 @@ export default defineComponent({
135137
})
136138
.catch((errors) => {
137139
this.error = true;
140+
this.errorshake = true;
141+
setTimeout(() => {
142+
this.errorshake = false;
143+
}, 300);
138144
console.log("Cannot log in"+errors)
139145
})
140146
}
@@ -158,4 +164,18 @@ export default defineComponent({
158164
}
159165
}
160166
});
161-
</script>
167+
</script>
168+
169+
<style scoped>
170+
/* https://unused-css.com/blog/css-shake-animation/ */
171+
@keyframes horizontal-shaking {
172+
0% { transform: translateX(0) }
173+
25% { transform: translateX(5px) }
174+
50% { transform: translateX(-5px) }
175+
75% { transform: translateX(5px) }
176+
100% { transform: translateX(0) }
177+
}
178+
.shaking {
179+
animation: horizontal-shaking 0.3s ease-in-out;
180+
}
181+
</style>

0 commit comments

Comments
 (0)