I want to apply a CSS animation to any given input field, depending on which value was typed into it.
My .svelte file looks something like this:
<script>
let letterPlaceHolder = new Array(50)
async function submit() {
//Make fetch to backend with all input values.
//Backend returns list of which letters are valid and invalid.
}
</script>
{#each Array(50) as input, i}
<input
type="text"
maxlength="1"
bind:this={letterPlaceHolder[i]}
/>
{/each}
<button id="submit" on:click={submit}>Submit</button>
When the submit function is called, I get a return from the backend, telling me which letters are valid and which are invalid. I want to apply a Boop animation to all elements with an invalid letter. See the example of Boop action here: https://svelte.dev/repl/e606c27c864045e5a9700691a7417f99?version=3.48.0
How can I apply a Boop animation to selected input elements, that are triggered by the response of the backed?
I'm guessing that I need to import a svelte component that animates any given DOM element that I feed it, but I'm not sure how to solve this.