Skip to content

Commit 035b0f7

Browse files
committed
improve dashboard config cards UX
- Make entire card clickable to edit (with keyboard support) - Show last modified date (Today/Yesterday/X days ago) - Copy button shows 'Copied!' feedback for 2 seconds - Add hover shadow effect on cards
1 parent 95e3b7a commit 035b0f7

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/routes/dashboard/+page.svelte

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
packages?: string[];
1818
custom_script?: string;
1919
dotfiles_repo?: string;
20+
updated_at?: string;
2021
}
2122
23+
let copiedId = $state('');
24+
2225
let configs = $state<Config[]>([]);
2326
let loading = $state(true);
2427
let showModal = $state(false);
@@ -254,10 +257,22 @@
254257
}
255258
}
256259
257-
function copyToClipboard(text: string) {
260+
function copyToClipboard(text: string, configId: string) {
258261
navigator.clipboard.writeText(text);
259-
toast = 'Copied!';
260-
setTimeout(() => toast = '', 2000);
262+
copiedId = configId;
263+
setTimeout(() => copiedId = '', 2000);
264+
}
265+
266+
function formatDate(dateStr?: string): string {
267+
if (!dateStr) return '';
268+
const date = new Date(dateStr + 'Z');
269+
const now = new Date();
270+
const diff = now.getTime() - date.getTime();
271+
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
272+
if (days === 0) return 'Today';
273+
if (days === 1) return 'Yesterday';
274+
if (days < 7) return `${days} days ago`;
275+
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
261276
}
262277
263278
function getInstallUrl(config: Config): string {
@@ -301,7 +316,7 @@
301316
{:else}
302317
<div class="configs-grid">
303318
{#each configs as config}
304-
<div class="config-card">
319+
<div class="config-card" onclick={() => editConfig(config.slug)} role="button" tabindex="0" onkeydown={(e) => e.key === 'Enter' && editConfig(config.slug)}>
305320
<div class="config-header">
306321
<div>
307322
<div class="config-name">{config.name}</div>
@@ -322,12 +337,15 @@
322337
{/if}
323338
<div class="config-meta">
324339
<span class="config-meta-item">Preset: <strong>{config.base_preset}</strong></span>
340+
{#if config.updated_at}
341+
<span class="config-meta-item">Modified: <strong>{formatDate(config.updated_at)}</strong></span>
342+
{/if}
325343
</div>
326-
<div class="config-url">
344+
<div class="config-url" onclick={(e) => e.stopPropagation()}>
327345
<code>curl -fsSL {getInstallUrl(config)} | bash</code>
328-
<button class="copy-btn" onclick={() => copyToClipboard(`curl -fsSL https://${getInstallUrl(config)} | bash`)}>Copy</button>
346+
<button class="copy-btn" onclick={() => copyToClipboard(`curl -fsSL https://${getInstallUrl(config)} | bash`, config.id)}>{copiedId === config.id ? 'Copied!' : 'Copy'}</button>
329347
</div>
330-
<div class="config-actions">
348+
<div class="config-actions" onclick={(e) => e.stopPropagation()}>
331349
<Button variant="secondary" onclick={() => editConfig(config.slug)}>Edit</Button>
332350
<Button variant="danger" onclick={() => deleteConfig(config.slug)}>Delete</Button>
333351
</div>
@@ -563,10 +581,12 @@
563581
border-radius: 12px;
564582
padding: 20px;
565583
transition: all 0.2s;
584+
cursor: pointer;
566585
}
567586
568587
.config-card:hover {
569588
border-color: var(--border-hover);
589+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
570590
}
571591
572592
.config-header {

0 commit comments

Comments
 (0)