Improved table logic.
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<main id="main-content" tabindex="-1" class="min-w-0 px-4 py-8 focus:outline-none sm:px-10">
|
||||
<main class="min-w-0 px-4 py-8">
|
||||
<div class="mx-auto max-w-6xl">
|
||||
{@render children()}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,57 @@
|
||||
<script lang="ts">
|
||||
import Table, { type Column } from '#lib/components/table.svelte';
|
||||
|
||||
type ScheduledTransaction = {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
account: string;
|
||||
amount: number;
|
||||
};
|
||||
|
||||
const columns: Column<ScheduledTransaction>[] = [
|
||||
{ key: 'name', label: 'Name', ratio: 1 },
|
||||
{ key: 'account', label: 'Account' },
|
||||
{ key: 'amount', label: 'Amount' }
|
||||
];
|
||||
const data: ScheduledTransaction[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Some transaction',
|
||||
description: 'Some description',
|
||||
account: 'Some account',
|
||||
amount: 100
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Another transaction',
|
||||
description: 'Another description',
|
||||
account: 'Another account',
|
||||
amount: 200
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Yet another transaction',
|
||||
description: 'Yet another description, but longer than the others',
|
||||
account: 'Yet another account',
|
||||
amount: 300
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Scheduled transactions | Expenses</title>
|
||||
</svelte:head>
|
||||
|
||||
<Table {columns} {data}>
|
||||
{#snippet header(col)}
|
||||
{col.label}
|
||||
{/snippet}
|
||||
{#snippet cell(ctx)}
|
||||
{#if ctx.key === 'name'}
|
||||
{ctx.value}
|
||||
{:else}
|
||||
{ctx.value}
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Table>
|
||||
|
||||
Reference in New Issue
Block a user