feat: add aria label, fix test, transition constant for better testing

This commit is contained in:
2026-02-09 09:37:13 +05:00
parent ede31942d0
commit 2bbe59107c
12 changed files with 232 additions and 32 deletions
+4 -3
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import Button from "$components/ui/Button.svelte";
import { TRANSITION_DURATION } from "$lib/constants";
import { fly } from "svelte/transition";
import Cross from "~icons/lucide/x";
@@ -12,10 +13,10 @@
let { text = $bindable(), id, ondelete }: Props = $props();
</script>
<div class="text-item" transition:fly={{ x: 600, duration: 300 }}>
<li class="text-item" transition:fly={{ x: 600, duration: TRANSITION_DURATION }}>
<input type="text" bind:value={text} />
<Button icon={Cross} type="danger" onclick={() => ondelete(id)} />
</div>
<Button icon={Cross} ariaLabel="Delete" type="danger" onclick={() => ondelete(id)} />
</li>
<style>
.text-item {
+10 -2
View File
@@ -1,10 +1,11 @@
<script lang="ts">
interface Props {
text: string;
ariaLabel: string;
onenter: () => void;
}
let { text = $bindable(), onenter }: Props = $props();
let { text = $bindable(), onenter, ariaLabel }: Props = $props();
function handleKeyboard(event: KeyboardEvent) {
if (event.key === "Enter") {
@@ -13,7 +14,14 @@
}
</script>
<input bind:value={text} class="text-input" type="text" placeholder="Введите текст..." onkeydown={handleKeyboard} />
<input
aria-label={ariaLabel}
bind:value={text}
class="text-input"
type="text"
placeholder="Введите текст..."
onkeydown={handleKeyboard}
/>
<style>
.text-input {
+4 -4
View File
@@ -21,14 +21,14 @@
<Card title="Тексты панелей">
<InputGroup>
<TextInput bind:text onenter={addText} />
<Button icon={Plus} onclick={addText} />
<TextInput ariaLabel="Input new text" bind:text onenter={addText} />
<Button icon={Plus} ariaLabel="Add text" onclick={addText} />
</InputGroup>
<div class="texts-list">
<ul class="texts-list">
{#each textsState.texts as { text, id } (id)}
<TextInlineEdit {id} {text} ondelete={() => deleteText(id)} />
{/each}
</div>
</ul>
</Card>
<style>