fix: resolve texts add and delete flow

This commit is contained in:
2026-02-05 18:35:13 +05:00
parent a5cea0ab57
commit 1b8a035708
5 changed files with 14 additions and 10 deletions
+3 -2
View File
@@ -4,15 +4,16 @@
interface Props {
text: string;
id: number;
ondelete: () => void;
}
let { text = $bindable(), ondelete }: Props = $props();
let { text = $bindable(), id, ondelete }: Props = $props();
</script>
<div class="text-item">
<input type="text" bind:value={text} />
<Button icon={IconCross} type="danger" on:click={ondelete} />
<Button icon={IconCross} type="danger" onclick={() => ondelete(id)} />
</div>
<style>
+8 -4
View File
@@ -10,11 +10,16 @@
let text: string = $state("");
function addText() {
console.log(text);
let trimmed = text.trim();
if (trimmed.length !== 0) {
textsState.addText(trimmed);
}
text = "";
}
function deleteText(id: number) {}
function deleteText(id: number) {
textsState.removeText(id);
}
</script>
<Card title="Тексты панелей">
@@ -24,13 +29,12 @@
</InputGroup>
<div class="texts-list">
{#each textsState.texts as { text, id } (id)}
<TextInlineEdit {text} ondelete={() => deleteText(id)} />
<TextInlineEdit {id} {text} ondelete={() => deleteText(id)} />
{/each}
</div>
</Card>
<style>
/* Texts List */
.texts-list {
display: flex;
flex-direction: column;