Redesign scans home screen

This commit is contained in:
iamdoubz committed 2026-11-05 17:41:32 -06:00
1 parent e8d4270c89
commit 61f37ac942
1 file changed
+123 -45
+123 -45
View File
@@ -1,7 +1,15 @@
<script lang="ts">
import Camera from '@lucide/svelte/icons/camera';
import ChevronRight from '@lucide/svelte/icons/chevron-right';
import CircleCheck from '@lucide/svelte/icons/circle-check';
import Circle from '@lucide/svelte/icons/circle';
import ScanLine from '@lucide/svelte/icons/scan-line';
import { api, type ScanSummary } from '../lib/api';
import { app } from '../lib/state.svelte';
import { monthLabel } from '../lib/dates';
import { LAYOUT_ICONS } from '../lib/icons';
import PageHeader from '../lib/ui/PageHeader.svelte';
import EmptyState from '../lib/ui/EmptyState.svelte';
import StatusBadge from './StatusBadge.svelte';
let scans = $state<ScanSummary[] | null>(null);
@@ -26,58 +34,128 @@
const h = $derived(app.household!);
const setup = $derived([
{ done: h.children.length > 0, text: 'Add your children' },
{ done: h.sources.length > 0, text: 'Add the paper calendars and menus you get (sources)' },
{ done: h.sources.length > 0, text: 'Add what you scan: the school calendar, a menu, flyers' },
{ done: h.calendars.length > 0, text: 'Add a calendar to send events to' },
]);
const doneCount = $derived(setup.filter((s) => s.done).length);
const waiting = $derived(scans?.filter((s) => ['queued', 'parsed', 'reviewed', 'failed'].includes(s.status)) ?? []);
const rest = $derived(scans?.filter((s) => !waiting.includes(s)) ?? []);
const layoutOf = (s: ScanSummary) => h.sources.find((x) => x.id === s.source_id)?.layout_type ?? 'month_grid';
</script>
<h1>ParentCalendar</h1>
<PageHeader title="Scans" subtitle="Turn paper calendars and lunch menus into calendar events." />
{#if setup.some((s) => !s.done)}
<section class="card stack">
<h2 style="margin-top:0">Get started</h2>
<ol>
{#each setup as step}
<li class:done={step.done}>{step.text}</li>
{/each}
</ol>
<a class="button" href="#/settings">Open settings</a>
</section>
{/if}
<div class="stack-lg">
{#if doneCount < setup.length}
<section class="card setup" aria-labelledby="setup-title">
<div class="row spread">
<h2 id="setup-title">Get started</h2>
<span class="badge info tabular">{doneCount} of {setup.length} done</span>
</div>
<ul class="steps">
{#each setup as step}
<li class:done={step.done}>
{#if step.done}<CircleCheck size={20} aria-hidden="true" />{:else}<Circle size={20} aria-hidden="true" />{/if}
<span>{step.text}</span>
<span class="visually-hidden">{step.done ? '(done)' : '(to do)'}</span>
</li>
{/each}
</ul>
<a class="btn primary" href="#/settings">Open settings</a>
</section>
{/if}
<a class="button primary scan" href="#/new">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 8a2 2 0 0 1 2-2h2l2-2h4l2 2h2a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zM12 17a4 4 0 1 0 0-8 4 4 0 0 0 0 8z" /></svg>
Scan a calendar or menu
</a>
<a class="scan-cta" href="#/new">
<span class="cta-icon"><Camera size={26} aria-hidden="true" /></span>
<span class="grow">
<span class="cta-title">Scan a calendar or menu</span>
<span class="cta-sub">Take a photo, or pick a screenshot or PDF</span>
</span>
<ChevronRight size={22} aria-hidden="true" />
</a>
<h2>Recent scans</h2>
{#if error}
<p class="error">{error}</p>
{:else if scans === null}
<p class="muted">Loading…</p>
{:else if scans.length === 0}
<p class="empty">No scans yet.</p>
{:else}
<ul class="list">
{#each scans as s (s.id)}
<li>
<a class="card row spread" href={`#/scan/${s.id}`}>
<span>
<strong>{s.source_name}</strong><br />
<span class="muted small">{monthLabel(s.hint_month)} · {s.event_count} events</span>
</span>
<StatusBadge status={s.status} />
</a>
</li>
{/each}
</ul>
{/if}
{#if error}
<div class="alert error" role="alert">{error}</div>
{:else if scans === null}
<div class="stack" aria-busy="true" aria-label="Loading scans">
{#each [1, 2, 3] as _}<div class="skeleton" style="height:72px"></div>{/each}
</div>
{:else if scans.length === 0}
<EmptyState icon={ScanLine} title="No scans yet">
<p>Your first scan shows up here while it's read, then waits for you to review it.</p>
</EmptyState>
{:else}
{#snippet list(items: ScanSummary[])}
<ul class="card-list">
{#each items as s (s.id)}
{@const Icon = LAYOUT_ICONS[layoutOf(s)]}
<li>
<a class="scan" href={`#/scan/${s.id}`}>
<span class="kind"><Icon size={20} aria-hidden="true" /></span>
<span class="grow">
<span class="name">{s.source_name}</span>
<span class="meta">{monthLabel(s.hint_month)} · {s.event_count} {s.event_count === 1 ? 'event' : 'events'}</span>
</span>
<StatusBadge status={s.status} />
<ChevronRight size={18} class="chev" aria-hidden="true" />
</a>
</li>
{/each}
</ul>
{/snippet}
{#if waiting.length}
<section class="section">
<h2 class="section-title">Needs you <span class="count">{waiting.length}</span></h2>
{@render list(waiting)}
</section>
{/if}
{#if rest.length}
<section class="section">
<h2 class="section-title">Recent <span class="count">{rest.length}</span></h2>
{@render list(rest)}
</section>
{/if}
{/if}
</div>
<style>
.scan { width: 100%; min-height: 56px; font-size: 1.05rem; margin-top: 8px; }
.scan svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
ol { margin: 0; padding-left: 20px; }
li.done { color: var(--muted); text-decoration: line-through; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list a { color: var(--text); text-decoration: none; min-height: 56px; }
.setup { display: flex; flex-direction: column; gap: var(--s4); }
.setup .btn { align-self: flex-start; }
.steps { display: flex; flex-direction: column; gap: var(--s3); }
.steps li { display: flex; gap: var(--s3); align-items: flex-start; color: var(--text-3); }
.steps li:not(.done) { color: var(--text); }
.steps li.done span:not(.visually-hidden) { text-decoration: line-through; color: var(--text-3); }
.steps li.done :global(svg) { color: var(--ok); }
.scan-cta {
display: flex; align-items: center; gap: var(--s4);
padding: var(--s5) var(--s4); border-radius: var(--r-lg);
background: var(--primary); color: var(--on-primary); text-decoration: none;
box-shadow: var(--shadow-2);
transition: transform var(--dur-out) var(--ease), background-color var(--dur) var(--ease);
}
.scan-cta:hover { background: var(--primary-hover); }
.scan-cta:active { transform: scale(0.98); }
.cta-icon {
display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r-md);
background: color-mix(in srgb, var(--on-primary) 16%, transparent); flex: none;
}
.cta-title { display: block; font-size: var(--fs-lg); font-weight: 750; }
.cta-sub { display: block; font-size: var(--fs-sm); opacity: 0.85; }
.scan {
display: flex; align-items: center; gap: var(--s3);
padding: var(--s3) var(--s4); min-height: 72px;
background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
color: var(--text); text-decoration: none; box-shadow: var(--shadow-1);
transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.scan:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.kind {
display: grid; place-items: center; width: 40px; height: 40px; flex: none;
border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2);
}
.name { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: block; font-size: var(--fs-sm); color: var(--text-2); }
.scan :global(.chev) { color: var(--text-3); flex: none; }
</style>