Refactor Commander card layout and delete dialog

- Convert `label` element to `p` tag with `text-sm` class
- Restructure color identity section from single flex to multi-column
  grid
- Add `tabindex="-1"` to dialog overlay for proper keyboard focus
  management
- Add `on:keydown` handler to dialog overlay to prevent default key
  actions
- Improve delete dialog spacing and typography
This commit is contained in:
2026-04-11 19:13:35 +02:00
parent e3c421a52e
commit 24510001b5
2 changed files with 25 additions and 17 deletions

View File

@@ -205,6 +205,25 @@
};
}
function closeDeleteDialog() {
if (!deleteConfirm.deleting) {
deleteConfirm.show = false;
}
}
function handleOverlayClick(event) {
if (event.target === event.currentTarget) {
closeDeleteDialog();
}
}
function handleDeleteDialogKeydown(event) {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
closeDeleteDialog();
}
}
async function handleDelete() {
deleteConfirm.deleting = true;
try {
@@ -287,9 +306,9 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
<p class="block text-sm font-medium text-gray-700 mb-2">
Color Identity
</label>
</p>
<div class="flex gap-3">
{#each mtgColors as color}
<button
@@ -358,7 +377,7 @@
</button>
</div>
{:else}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
{#each commanders as commander}
<div class="card hover:shadow-lg transition-shadow">
<!-- Header with name and actions -->
@@ -435,14 +454,14 @@
{#if deleteConfirm.show}
<div
class="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50"
on:click={() =>
!deleteConfirm.deleting && (deleteConfirm.show = false)}
on:click={handleOverlayClick}
on:keydown={handleDeleteDialogKeydown}
role="dialog"
aria-modal="true"
tabindex="-1"
>
<div
class="bg-white rounded-lg p-6 max-w-sm w-full mx-4"
on:click|stopPropagation
role="document"
>
<h3 class="text-lg font-bold text-gray-900 mb-2">

View File

@@ -185,17 +185,6 @@
year: "numeric",
});
}
function getColorName(color) {
const colorNames = {
W: "White",
U: "Blue",
B: "Black",
R: "Red",
G: "Green",
};
return colorNames[color] || color;
}
</script>
<svelte:head>