From c817cc868144b90d1fa632512b153736b22c7bad Mon Sep 17 00:00:00 2001 From: ZXY101 Date: Mon, 8 Jan 2024 06:47:30 +0200 Subject: [PATCH] Add catalog search, fix sorting --- src/lib/components/Catalog.svelte | 29 +++++++++++++++++++++++++---- src/routes/+page.svelte | 1 - 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/lib/components/Catalog.svelte b/src/lib/components/Catalog.svelte index 5806af5..a3519f3 100644 --- a/src/lib/components/Catalog.svelte +++ b/src/lib/components/Catalog.svelte @@ -1,17 +1,38 @@ {#if $catalog} {#if $catalog.length > 0}
-
- {#each $catalog as { id } (id)} - - {/each} +
+ +
+ {#if search && sortedCatalog.length === 0} +
+

No results found.

+
+ {:else} +
+ {#each sortedCatalog as { id } (id)} + + {/each} +
+ {/if}
{:else}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9ca74ec..a282226 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,6 +1,5 @@