aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/GroceryRow.svelte
blob: 3305afafe3ea9d90165933f56c2cd5af76376a72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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>