working on document editor

This commit is contained in:
2025-07-10 23:37:29 +02:00
parent 32e2d91ee6
commit 85b5ca1970
5 changed files with 92 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
<script>
let { editable = false, currency, value = $bindable(null) } = $props();
let editing = $state(false);
function toggleEdit(){
editing = !editing;
if (editing){
value /= 100;
}
}
function typed(ev){
if (ev.keyCode == 13) {
toggleEdit();
value *= 100;
}
}
</script>
<style>
input{width:100px}
</style>
{#if editable && editing}
<input type="number" step=".01" bind:value onkeyup={typed} />&nbsp;{currency}
{:else}
<div onclick={toggleEdit}>{Number(value/100).toFixed(2)}&nbsp;{currency}</div>
{/if}