Skip to content

Commit

Permalink
feat: ✨ add more visual feedback for invalid input
Browse files Browse the repository at this point in the history
  • Loading branch information
iamludal committed Dec 4, 2020
1 parent 3ddcb94 commit 7f87e14
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/components/Playground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
height: 100vh;
}
.playground.invalid {
animation: invalid 0.2s 2 alternate backwards;
}
.words-container {
height: 100vh;
width: 100vw;
Expand All @@ -67,32 +71,23 @@
transition: transform var(--transition);
}
.input.invalid {
animation: invalid 0.2s forwards linear;
}
.score {
opacity: 0.9;
padding: 0.5em;
}
@keyframes invalid {
0% {
transform: translateX(0);
}
25% {
transform: translateX(-10%);
}
75% {
transform: translateX(10%);
}
75%,
100% {
transform: translateX(0);
background-color: #db3434;
}
}
</style>

<div class="playground" transition:fade={{ duration: 500 }}>
<div
class="playground"
class:invalid={invalidInput}
transition:fade={{ duration: 500 }}>
<div class="words-container">
{#each fallingWords as props (props.id)}
<Word {props} />
Expand All @@ -113,7 +108,6 @@
bind:value={typedWord}
bind:this={input}
on:keyup={handleKeyUp}
on:blur={handleBlur}
class:invalid={invalidInput} />
on:blur={handleBlur} />
</div>
</div>

0 comments on commit 7f87e14

Please sign in to comment.