Skip to content

Commit 9bfd970

Browse files
committed
feat: Improve accessibility by adding 'for' attributes to labels and enhancing UI elements in contact details
1 parent 4664f7c commit 9bfd970

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

src/routes/(admin)/admin/contacts/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/** @type {{ data: import('./$types').PageData }} */
33
let { data } = $props();
44
5+
/** @param {string | Date} dateString */
56
const formatDate = (dateString) => {
67
return new Date(dateString).toLocaleDateString('en-US', {
78
year: 'numeric',

src/routes/(app)/app/contacts/+page.svelte

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@
149149
<div class="mt-4 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600">
150150
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
151151
<div>
152-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
152+
<label for="ownerSelect" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
153153
Owner
154154
</label>
155155
<select
156+
id="ownerSelect"
156157
bind:value={selectedOwner}
157158
class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
158159
>
@@ -301,7 +302,39 @@
301302
{formatDate(contact.createdAt)}
302303
</div>
303304
</td>
304-
305+
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
306+
<div class="flex items-center justify-end gap-2">
307+
<button
308+
onclick={() => goto(`/app/contacts/${contact.id}`)}
309+
class="p-1.5 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700"
310+
title="View contact"
311+
>
312+
<Eye class="w-4 h-4" />
313+
</button>
314+
<button
315+
onclick={() => editContact(contact)}
316+
class="p-1.5 text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700"
317+
title="Edit contact"
318+
>
319+
<Edit class="w-4 h-4" />
320+
</button>
321+
<form method="POST" action="?/delete" use:enhance class="inline">
322+
<input type="hidden" name="contactId" value={contact.id} />
323+
<button
324+
type="submit"
325+
class="p-1.5 text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700"
326+
title="Delete contact"
327+
onclick={(e) => {
328+
if (!confirm('Are you sure you want to delete this contact?')) {
329+
e.preventDefault();
330+
}
331+
}}
332+
>
333+
<Trash2 class="w-4 h-4" />
334+
</button>
335+
</form>
336+
</div>
337+
</td>
305338
</tr>
306339
{/each}
307340
</tbody>

src/routes/(app)/app/contacts/[contactId]/+page.svelte

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
124124
<div class="space-y-4">
125125
<div>
126-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Email</label>
126+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Email</span>
127127
{#if contact.email}
128128
<a href="mailto:{contact.email}" class="flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:underline mt-1">
129129
<Mail class="w-4 h-4" />
@@ -134,7 +134,7 @@
134134
{/if}
135135
</div>
136136
<div>
137-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Phone</label>
137+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Phone</span>
138138
{#if contact.phone}
139139
<a href="tel:{contact.phone}" class="flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:underline mt-1">
140140
<Phone class="w-4 h-4" />
@@ -145,21 +145,21 @@
145145
{/if}
146146
</div>
147147
<div>
148-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Department</label>
148+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Department</span>
149149
<p class="text-gray-900 dark:text-white mt-1">{contact.department || 'N/A'}</p>
150150
</div>
151151
</div>
152152
<div class="space-y-4">
153153
<div>
154-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Title</label>
154+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Title</span>
155155
<p class="text-gray-900 dark:text-white mt-1">{contact.title || 'N/A'}</p>
156156
</div>
157157
<div>
158-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Owner</label>
158+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Owner</span>
159159
<p class="text-gray-900 dark:text-white mt-1">{contact.owner?.name || 'N/A'}</p>
160160
</div>
161161
<div>
162-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Created</label>
162+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Created</span>
163163
<p class="text-gray-900 dark:text-white mt-1 flex items-center gap-2">
164164
<Calendar class="w-4 h-4" />
165165
{formatDate(contact.createdAt)}
@@ -169,7 +169,7 @@
169169
</div>
170170
{#if contact.description}
171171
<div class="mt-6 pt-6 border-t border-gray-200 dark:border-gray-700">
172-
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Description</label>
172+
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Description</span>
173173
<p class="text-gray-900 dark:text-white mt-2">{contact.description}</p>
174174
</div>
175175
{/if}
@@ -193,7 +193,7 @@
193193
{relationship.account.name}
194194
</a>
195195
{#if relationship.isPrimary}
196-
<span class="inline-flex px-2 py-0.5 text-xs bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 rounded-full flex items-center gap-1">
196+
<span class="flex px-2 py-0.5 text-xs bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 rounded-full items-center gap-1">
197197
<Star class="w-3 h-3" />
198198
Primary
199199
</span>

0 commit comments

Comments
 (0)