Refactored Svelte components

This commit is contained in:
Simon Cambier
2022-04-23 22:44:54 +02:00
parent 02d1a6a8ba
commit 9fdddb7f75
11 changed files with 92 additions and 80 deletions

View File

@@ -0,0 +1,29 @@
<script lang="ts">
import { debounce } from "obsidian"
import { createEventDispatcher, onMount, tick } from "svelte"
export let value = ''
const dispatch = createEventDispatcher()
let elInput: HTMLInputElement
onMount(async () => {
await tick()
elInput.focus()
elInput.select()
})
const debouncedOnInput = debounce(() => {
dispatch("input", value)
}, 100)
</script>
<input
bind:value
bind:this={elInput}
on:input={debouncedOnInput}
type="text"
class="prompt-input"
placeholder="Type to search through your notes"
spellcheck="false"
/>