aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-09-08 09:25:03 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-09-08 09:25:03 +0200
commit3148742b323ab71f1ef768a2f4dc353c00944034 (patch)
tree8f88990514fb58d11a8669b58a7265dbd3420fe0 /src/lib/components
parent7d85a18867ca0fe2310218c63cfc696c0f916171 (diff)
Share grocery row component and list-page form actions
- GroceryRow.svelte renders the toggle row (checkbox, name, best ref, arrow link) for both the list and catalog pages - grocery-actions.ts grows full form actions: addCategoryAction, addGroceryAction, addGroceryAndEditAction, deleteByIdAction; the categories/groceries route servers become thin wrappers
Diffstat (limited to 'src/lib/components')
-rw-r--r--src/lib/components/GroceryRow.svelte55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/components/GroceryRow.svelte b/src/lib/components/GroceryRow.svelte
new file mode 100644
index 0000000..3305afa
--- /dev/null
+++ b/src/lib/components/GroceryRow.svelte
@@ -0,0 +1,55 @@
+<script lang="ts">
+ import BestRef from '$lib/components/BestRef.svelte';
+ import type { EnrichedGrocery } from '$lib/server/services/groceries';
+
+ let {
+ item,
+ from,
+ selectable = false,
+ checked = false,
+ oncheck,
+ }: {
+ item: EnrichedGrocery;
+ from: string;
+ selectable?: boolean;
+ checked?: boolean;
+ oncheck?: () => void;
+ } = $props();
+</script>
+
+<li class="item-row item-row--fixed">
+ {#if selectable}
+ <input type="checkbox" class="item-check" {checked} onchange={oncheck} />
+ {/if}
+ <button
+ class="item-btn item-btn--grow"
+ name="id"
+ value={item.id}
+ type="submit"
+ aria-pressed={item.checked}
+ >
+ <span class="item-text">
+ <span class:checked={item.checked}>{item.name}</span>
+ {#if item.bestRef}
+ <BestRef ref={item.bestRef} />
+ {/if}
+ </span>
+ </button>
+ <a class="ref-link" href="/grocery/{item.id}?from={from}">&rarr;</a>
+</li>
+
+<style>
+ .item-check {
+ width: 1.25rem;
+ height: 1.25rem;
+ accent-color: var(--accent);
+ cursor: pointer;
+ flex-shrink: 0;
+ }
+
+ .checked {
+ text-decoration: line-through;
+ color: var(--text-secondary);
+ font-weight: 400;
+ }
+</style>