24 lines
490 B
Svelte
24 lines
490 B
Svelte
<script>
|
|
import { createEventDispatcher } from 'svelte'
|
|
const dispatch = createEventDispatcher()
|
|
|
|
function handleKeyup(e) {
|
|
if (e.key === "Enter") {
|
|
e.preventDefault()
|
|
dispatch('added', e.srcElement.value)
|
|
e.srcElement.value = ""
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<input type="text" on:keyup={handleKeyup}>
|
|
|
|
<style>
|
|
input {
|
|
width: 100%;
|
|
padding: 0.5rem;
|
|
box-sizing: border-box;
|
|
border: 1px solid var(--gray-400);
|
|
border-radius: 0.15rem;
|
|
}
|
|
</style> |