This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
comicinfo-editor-v2/src/lib/ListTextInput/ListTextInputElement.svelte

26 lines
No EOL
631 B
Svelte

<script lang="ts">
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
export let id: number;
export let value: string;
let width: number;
$: width = Math.max(value.length + 3, 6);
const handleClick = () => {
dispatch('deleted', {
tagId: id,
});
}
</script>
<input id="tag-{id}" type="text" class="letterInput" style="--valuelen: {width}ch" bind:value={value} autofocus>
<button on:click|preventDefault={handleClick}>X</button>
<style>
.letterInput {
width: var(--valuelen);
padding-left: 1ch;
}
</style>