aboutsummaryrefslogtreecommitdiff
path: root/src/routes/+page.svelte
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-07-27 16:54:28 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-07-27 16:54:28 +0200
commit71ca66bcba70f7a463df6ee9bdcb0e14b8e60595 (patch)
tree6e962f0d8c3346fd871cb337f9c5a14e4c0f0a08 /src/routes/+page.svelte
parented39c60ebc10efe2b644172e7c82f943c4fba3cc (diff)
feat: minimal grocery list — add items, check them off
- Groceries DB schema (id, name, checked, created_at) with Drizzle + libsql - /+page.server.ts: load (unchecked items, newest first), add & toggle actions - /+page.svelte: text input + Add button, item list with toggle buttons - Mobile-first styling with scoped CSS classes - AGENTS.md: project-specific rules including UI validation
Diffstat (limited to 'src/routes/+page.svelte')
-rw-r--r--src/routes/+page.svelte95
1 files changed, 93 insertions, 2 deletions
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 1b6e963..fc56140 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -1,6 +1,97 @@
<script>
import '../app.css';
+ import { enhance } from '$app/forms';
+
+ let { data, form } = $props();
+ let name = $state('');
</script>
-<h1>Home</h1>
-<p>Welcome! Groceries and chores coming soon.</p>
+<h1>Groceries</h1>
+
+<form class="add-form" method="POST" action="?/add" use:enhance>
+ <input
+ type="text"
+ name="name"
+ bind:value={name}
+ placeholder="Add an item..."
+ autocomplete="off"
+ />
+ <button type="submit">Add</button>
+</form>
+
+{#if form?.error}
+ <p class="error">{form.error}</p>
+{/if}
+
+<hr />
+
+<form method="POST" action="?/toggle" use:enhance>
+ <ul class="item-list">
+ {#each data?.items ?? [] as item (item.id)}
+ <li>
+ <button name="id" value={item.id} type="submit">
+ {item.name}
+ </button>
+ </li>
+ {/each}
+ </ul>
+</form>
+
+<style>
+ .add-form {
+ display: flex;
+ gap: 0.5rem;
+ margin-bottom: 1rem;
+ }
+
+ input {
+ flex: 1;
+ padding: 0.75rem;
+ border: 1px solid #ccc;
+ border-radius: 0.5rem;
+ font-size: 1rem;
+ }
+
+ .add-form button[type='submit'] {
+ padding: 0.75rem 1.25rem;
+ border: none;
+ border-radius: 0.5rem;
+ background: #333;
+ color: #fff;
+ font-size: 1rem;
+ }
+
+ .error {
+ color: #d00;
+ margin-top: -0.5rem;
+ margin-bottom: 1rem;
+ }
+
+ hr {
+ border: none;
+ border-top: 1px solid #ddd;
+ margin: 1.5rem 0;
+ }
+
+ .item-list {
+ list-style: none;
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ }
+
+ .item-list li button {
+ width: 100%;
+ text-align: left;
+ padding: 0.75rem;
+ border: 1px solid #e0e0e0;
+ border-radius: 0.5rem;
+ background: #fff;
+ font-size: 1rem;
+ transition: background 0.15s;
+ }
+
+ .item-list li button:hover {
+ background: #f5f5f5;
+ }
+</style>