fix: resolve texts add and delete flow
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user