Ditched component mockups. I'd like to build them myself.

This commit is contained in:
2026-10-22 21:48:16 +02:00
parent a34fd7b7fd
commit cf68405c44
23 changed files with 0 additions and 1243 deletions
-93
View File
@@ -1,99 +1,6 @@
<script lang="ts">
import ActivityRow from '#lib/components/ActivityRow.svelte';
import Amount from '#lib/components/Amount.svelte';
import Button from '#lib/components/Button.svelte';
import Card from '#lib/components/Card.svelte';
import EmptyState from '#lib/components/EmptyState.svelte';
import Link from '#lib/components/Link.svelte';
import Notice from '#lib/components/Notice.svelte';
import PageHeader from '#lib/components/PageHeader.svelte';
import { formatDate } from '#lib/format.ts';
import { accounts, transactions } from '#lib/mock/data.ts';
let selectedId = $state(accounts[0].id);
let showNotice = $state(true);
const selected = $derived(accounts.find((account) => account.id === selectedId) ?? accounts[0]);
const activity = $derived(
transactions
.filter((transaction) => transaction.accountId === selected.id)
.toSorted((a, b) => b.date.localeCompare(a.date))
.slice(0, 5)
);
function lastActivity(accountId: string) {
const dates = transactions.filter((t) => t.accountId === accountId).map((t) => t.date);
return dates.length ? formatDate(dates.toSorted().at(-1)!) : 'none yet';
}
</script>
<svelte:head>
<title>Accounts | Expenses</title>
</svelte:head>
<PageHeader title="Accounts" description={`${accounts.length} accounts`}>
{#snippet actions()}
<Button variant="primary" icon="plus">New account</Button>
{/snippet}
</PageHeader>
{#if showNotice}
<div class="mb-8">
<Notice onclose={() => (showNotice = false)}>Checking Account reconciled on 19 Oct 2026.</Notice
>
</div>
{/if}
<ul class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{#each accounts as account (account.id)}
<li>
<button
type="button"
aria-pressed={account.id === selectedId}
onclick={() => (selectedId = account.id)}
class="block h-full w-full rounded border border-neutral-600 bg-neutral-950 p-5 text-left hover:border-neutral-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-300 aria-pressed:border-neutral-300"
>
<span class="block text-sm text-neutral-400">{account.name}</span>
<Amount
cents={account.balanceCents}
showCurrency
class="mt-3 block text-xl wrap-anywhere sm:text-2xl"
/>
<span class="mt-4 block text-sm text-neutral-500">
{account.memberCount === 1 ? '1 member' : `${account.memberCount} members`} / Last activity:
{lastActivity(account.id)}
</span>
</button>
</li>
{/each}
</ul>
<h2 class="mt-12 mb-4 text-2xl font-normal">{selected.name}</h2>
<Card title="Recent activity">
{#snippet actions()}
<Link href="/transaction-history">View all</Link>
{/snippet}
{#if activity.length}
<ul class="divide-y divide-neutral-700 border-t border-neutral-700">
{#each activity as transaction (transaction.id)}
<ActivityRow
title={transaction.description}
subtitle={formatDate(transaction.date)}
cents={transaction.amountCents}
direction={transaction.direction}
/>
{/each}
</ul>
{:else}
<div class="border-t border-neutral-700 px-5 py-8">
<EmptyState
title="No transactions yet"
description="New transactions for this account will appear here."
>
{#snippet action()}
<Link href="/transaction-history">Add a transaction</Link>
{/snippet}
</EmptyState>
</div>
{/if}
</Card>
@@ -1,150 +1,6 @@
<script lang="ts">
import Amount from '#lib/components/Amount.svelte';
import Button from '#lib/components/Button.svelte';
import Card from '#lib/components/Card.svelte';
import DataTable, { type Column } from '#lib/components/DataTable.svelte';
import EmptyState from '#lib/components/EmptyState.svelte';
import Notice from '#lib/components/Notice.svelte';
import PageHeader from '#lib/components/PageHeader.svelte';
import SearchInput from '#lib/components/SearchInput.svelte';
import SegmentedControl from '#lib/components/SegmentedControl.svelte';
import StatusDot from '#lib/components/StatusDot.svelte';
import {
formatDate,
formatRecurrence,
formatWeekendAdjustment,
monthlyCents,
signedCents
} from '#lib/format.ts';
import { accounts, scheduledTransactions } from '#lib/mock/data.ts';
import type { ScheduledTransaction, ScheduleStatus } from '#lib/types.ts';
const columns: Column[] = [
{ key: 'name', label: 'Name' },
{ key: 'account', label: 'Account' },
{ key: 'recurrence', label: 'Recurrence' },
{ key: 'nextDue', label: 'Next due' },
{ key: 'status', label: 'Status' },
{ key: 'amount', label: 'Amount / EUR', align: 'right' }
];
const statuses: Record<
ScheduleStatus,
{ kind: 'solid' | 'hollow' | 'dash' | 'alert'; label: string }
> = {
active: { kind: 'solid', label: 'Active' },
'due-soon': { kind: 'alert', label: 'Due soon' },
paused: { kind: 'hollow', label: 'Paused' },
ended: { kind: 'dash', label: 'Ended' }
};
let direction = $state('all');
let query = $state('');
const accountName = (id: string) => accounts.find((account) => account.id === id)?.name ?? '';
const rows = $derived(
scheduledTransactions.filter(
(item) =>
(direction === 'all' || item.direction === direction) &&
item.name.toLowerCase().includes(query.trim().toLowerCase())
)
);
const monthlyNet = $derived(
rows
.filter((item) => item.status === 'active' || item.status === 'due-soon')
.reduce((sum, item) => sum + signedCents(monthlyCents(item), item.direction), 0)
);
const upcoming = scheduledTransactions
.filter((item) => item.status === 'due-soon' && item.nextDue)
.toSorted((a, b) => a.nextDue!.localeCompare(b.nextDue!))[0];
function recurrenceNotes(item: ScheduledTransaction) {
return [
formatWeekendAdjustment(item.weekendAdjustment),
item.endsAt && `Until ${formatDate(item.endsAt)}`
].filter((note): note is string => Boolean(note));
}
</script>
<svelte:head>
<title>Scheduled transactions | Expenses</title>
</svelte:head>
<PageHeader
title="Scheduled transactions"
description="Recurring income and expenses, booked automatically."
>
{#snippet actions()}
<Button variant="primary" icon="plus">New schedule</Button>
{/snippet}
</PageHeader>
{#if upcoming}
<div class="mb-8">
<Notice variant="warning">
{upcoming.name} is due on {formatDate(upcoming.nextDue!)}.
{#snippet action()}
<span class="text-neutral-400">{formatWeekendAdjustment(upcoming.weekendAdjustment)}</span>
{/snippet}
</Notice>
</div>
{/if}
<div class="mb-6 flex flex-wrap items-center gap-4">
<SearchInput
bind:value={query}
label="Search scheduled transactions"
placeholder="Search schedules..."
class="w-full sm:w-auto sm:min-w-64 sm:flex-1"
/>
<SegmentedControl
bind:value={direction}
label="Direction"
options={[
{ value: 'all', label: 'All' },
{ value: 'in', label: 'Income' },
{ value: 'out', label: 'Expenses' }
]}
/>
</div>
<Card>
<DataTable caption="Scheduled transactions" {columns} {rows} rowId={(item) => item.id}>
{#snippet cell(item, column)}
{#if column.key === 'name'}
{item.name}
{:else if column.key === 'account'}
<span class="text-neutral-400">{accountName(item.accountId)}</span>
{:else if column.key === 'recurrence'}
{formatRecurrence(item.every, item.unit)}
{#each recurrenceNotes(item) as note (note)}
<span class="block text-sm text-neutral-500">{note}</span>
{/each}
{:else if column.key === 'nextDue'}
<span class="text-neutral-400 tabular-nums">
{item.nextDue ? formatDate(item.nextDue) : '-'}
</span>
{:else if column.key === 'status'}
<StatusDot {...statuses[item.status]} muted={item.status !== 'due-soon'} />
{:else}
<Amount cents={item.amountCents} direction={item.direction} />
{/if}
{/snippet}
{#snippet empty()}
<EmptyState
title="No scheduled transactions"
description="Try a different search or filter."
/>
{/snippet}
{#snippet footer()}
<span class="text-neutral-400">{rows.length} schedules</span>
<span>
Monthly net
<Amount cents={monthlyNet} direction={monthlyNet < 0 ? 'out' : 'in'} showCurrency />
</span>
{/snippet}
</DataTable>
</Card>
@@ -1,136 +1,6 @@
<script lang="ts">
import Amount from '#lib/components/Amount.svelte';
import Button from '#lib/components/Button.svelte';
import Card from '#lib/components/Card.svelte';
import DataTable, { type Column } from '#lib/components/DataTable.svelte';
import EmptyState from '#lib/components/EmptyState.svelte';
import PageHeader from '#lib/components/PageHeader.svelte';
import Pagination from '#lib/components/Pagination.svelte';
import SearchInput from '#lib/components/SearchInput.svelte';
import SegmentedControl from '#lib/components/SegmentedControl.svelte';
import SelectField from '#lib/components/SelectField.svelte';
import { formatDate, signedCents } from '#lib/format.ts';
import { accounts, transactions } from '#lib/mock/data.ts';
const PAGE_SIZE = 8;
const columns: Column[] = [
{ key: 'date', label: 'Date' },
{ key: 'description', label: 'Description' },
{ key: 'account', label: 'Account' },
{ key: 'amount', label: 'Amount / EUR', align: 'right' }
];
let query = $state('');
let accountId = $state('all');
let direction = $state('all');
let page = $state(1);
let selected = $state<string[]>([]);
const accountName = (id: string) => accounts.find((account) => account.id === id)?.name ?? '';
const filtered = $derived(
transactions
.filter(
(transaction) =>
(accountId === 'all' || transaction.accountId === accountId) &&
(direction === 'all' || transaction.direction === direction) &&
transaction.description.toLowerCase().includes(query.trim().toLowerCase())
)
.toSorted((a, b) => b.date.localeCompare(a.date))
);
const rows = $derived(filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE));
const selectedTotal = $derived(
transactions
.filter((transaction) => selected.includes(transaction.id))
.reduce((sum, t) => sum + signedCents(t.amountCents, t.direction), 0)
);
// Filters change the result set, so return to the first page.
$effect(() => {
void [query, accountId, direction];
page = 1;
});
</script>
<svelte:head>
<title>Transaction history | Expenses</title>
</svelte:head>
<PageHeader title="Transaction history" description="Every payment in and out of your accounts.">
{#snippet actions()}
<Button icon="download">Export</Button>
{/snippet}
</PageHeader>
<div class="mb-4 grid gap-4 md:grid-cols-[minmax(0,1fr)_16rem] md:items-end">
<SearchInput
bind:value={query}
label="Search transactions"
placeholder="Search transactions..."
/>
<SelectField
bind:value={accountId}
label="Account"
options={[
{ value: 'all', label: 'All accounts' },
...accounts.map((account) => ({ value: account.id, label: account.name }))
]}
/>
</div>
<div class="mb-6">
<SegmentedControl
bind:value={direction}
label="Direction"
options={[
{ value: 'all', label: 'All' },
{ value: 'in', label: 'Money in' },
{ value: 'out', label: 'Money out' }
]}
/>
</div>
<Card>
<DataTable
caption="Transaction history"
{columns}
{rows}
rowId={(transaction) => transaction.id}
selectable
bind:selected
>
{#snippet cell(transaction, column)}
{#if column.key === 'date'}
<span class="text-neutral-400 tabular-nums">{formatDate(transaction.date)}</span>
{:else if column.key === 'description'}
{transaction.description}
{:else if column.key === 'account'}
<span class="text-neutral-400">{accountName(transaction.accountId)}</span>
{:else}
<Amount cents={transaction.amountCents} direction={transaction.direction} />
{/if}
{/snippet}
{#snippet empty()}
<EmptyState
icon="search"
title="No transactions found"
description="Try a different search or filter."
/>
{/snippet}
{#snippet footer()}
{#if selected.length}
<span class="text-neutral-400">{selected.length} selected</span>
<span>
Total
<Amount cents={selectedTotal} direction={selectedTotal < 0 ? 'out' : 'in'} showCurrency />
</span>
{:else}
<span class="text-neutral-500">Select transactions to see their total.</span>
{/if}
{/snippet}
</DataTable>
</Card>
<div class="mt-6">
<Pagination bind:page pageSize={PAGE_SIZE} total={filtered.length} noun="transactions" />
</div>