diff --git a/src/lib/components/UnitFilter.svelte b/src/lib/components/UnitFilter.svelte index 7fc2d09..89e5768 100644 --- a/src/lib/components/UnitFilter.svelte +++ b/src/lib/components/UnitFilter.svelte @@ -9,10 +9,10 @@ let { units, - selectedUnitId = $bindable(""), + selectedUnitIds = $bindable([]), }: { units: UnitDoc[]; - selectedUnitId?: string; + selectedUnitIds?: string[]; } = $props(); let pinnedIds = $state([]); @@ -41,6 +41,12 @@ const canPinMore = $derived(pinnedIds.length < MAX_PINS); + function toggleUnit(unitId: string) { + selectedUnitIds = selectedUnitIds.includes(unitId) + ? selectedUnitIds.filter((id) => id !== unitId) + : [...selectedUnitIds, unitId]; + } + async function togglePin(unit: UnitDoc) { const token = getToken(); if (!token) { @@ -84,20 +90,13 @@ {/snippet}
- - {#each pinnedUnits as unit (unit._id)} @@ -118,8 +117,9 @@ diff --git a/src/lib/components/UnitRail.svelte b/src/lib/components/UnitRail.svelte deleted file mode 100644 index af640a7..0000000 --- a/src/lib/components/UnitRail.svelte +++ /dev/null @@ -1,157 +0,0 @@ - - -{#snippet pinIcon()} - -{/snippet} - -
- {#each pinnedUnits as unit (unit._id)} -
- - {#if authed} - - {/if} -
- {/each} - - {#each unpinnedUnits as unit (unit._id)} -
- - {#if authed} - - {/if} -
- {/each} -
- -{#if error} -

{error}

-{/if} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b791d17..beacf3b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,22 +1,41 @@ @@ -42,14 +61,23 @@
-

Units

+
+

{authed ? "Pinned units" : "Units"}

+ All units +
{#if loading}

Loading

{:else if error}

{error}

+ {:else if authed && pinnedUnits.length === 0} +

+ Pin units from the + Units + page to keep them here. +

{:else}
- +
- +
{/if}