Skip to content

Commit 716f376

Browse files
committed
🎨 Improve table layout and UX (#1526)
1 parent e0bbef9 commit 716f376

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
TableHeadCell,
1010
} from 'flowbite-svelte';
1111
12+
import TrashBinOutline from 'flowbite-svelte-icons/TrashBinOutline.svelte';
13+
1214
import GradeLabel from '$lib/components/GradeLabel.svelte';
1315
import ExternalLinkWrapper from '$lib/components/ExternalLinkWrapper.svelte';
1416
@@ -104,6 +106,8 @@
104106
105107
return task;
106108
}
109+
110+
let isDeleting = false;
107111
</script>
108112

109113
{#if workBookTasksForTable.length}
@@ -119,10 +123,10 @@
119123
>
120124
<TableHeadCell class="w-1/2 pl-0 truncate">問題名</TableHeadCell>
121125
<TableHeadCell class="w-1/3 hidden sm:table-cell truncate">出典</TableHeadCell>
122-
<TableHeadCell class="w-24 md:w-64 hidden sm:table-cell px-0 truncate"
123-
>一言(50文字以下)</TableHeadCell
124-
>
125-
<TableHeadCell class="w-6 text-center">
126+
<TableHeadCell class="w-24 md:w-64 hidden sm:table-cell px-0 truncate">
127+
一言(50文字以下)
128+
</TableHeadCell>
129+
<TableHeadCell class="w-12 xs:w-16 text-center">
126130
<span class="sr-only">編集</span>
127131
</TableHeadCell>
128132
</TableHead>
@@ -162,6 +166,7 @@
162166
<!-- 出典 -->
163167
<TableBodyCell
164168
class="xs:text-lg hidden sm:table-cell text-gray-700 dark:text-gray-300 truncate"
169+
aria-hidden={true}
165170
>
166171
{addContestNameToTaskIndex(
167172
task.contestId,
@@ -183,8 +188,25 @@
183188
</td>
184189

185190
<!-- 削除 -->
186-
<TableBodyCell on:click={() => removeWorkBookTask(task)}>
187-
<div class="flex justify-center items-center">削除</div>
191+
<TableBodyCell class="w-12 xs:w-16">
192+
<button
193+
type="button"
194+
class="flex justify-center items-center"
195+
on:click={() => {
196+
if (confirm('本当に削除しますか?')) {
197+
try {
198+
isDeleting = true;
199+
removeWorkBookTask(task);
200+
} finally {
201+
isDeleting = false;
202+
}
203+
}
204+
}}
205+
disabled={isDeleting}
206+
>
207+
<TrashBinOutline class="w-5 h-5 xs:w-6 xs:h-6" />
208+
<span class="sr-only">削除</span>
209+
</button>
188210
</TableBodyCell>
189211
</TableBodyRow>
190212
{/each}

0 commit comments

Comments
 (0)