SPA & Text Inputs
This commit is contained in:
parent
c7375caef1
commit
85f86a36e8
10 changed files with 80 additions and 21 deletions
src/lib
18
src/lib/TextInput.svelte
Normal file
18
src/lib/TextInput.svelte
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<script lang="ts">
|
||||
export let id: string;
|
||||
export let value: string = "";
|
||||
export let placeholder: string = "";
|
||||
|
||||
let width: number;
|
||||
|
||||
$: width = Math.max(value.length + 3, placeholder.length + 3);
|
||||
</script>
|
||||
|
||||
<input {id} type="text" class="letterInput" style="--valuelen: {width}ch" bind:value={value} {placeholder}>
|
||||
|
||||
<style>
|
||||
.letterInput {
|
||||
width: var(--valuelen);
|
||||
padding-left: 1ch;
|
||||
}
|
||||
</style>
|
||||
Reference in a new issue