🎨 Add SvgNotFound component and integrate it into search results; update globals for SVG request links

This commit is contained in:
pheralb
2025-09-16 13:45:23 +01:00
parent 789fc0ce72
commit 0f2f026803
4 changed files with 51 additions and 3 deletions
+36
View File
@@ -0,0 +1,36 @@
<script lang="ts">
import { globals } from "@/globals";
import { buttonVariants } from "@/components/ui/button";
import ArrowUpRight from "@lucide/svelte/icons/arrow-up-right";
import BoxesIcon from "@/components/ui/moving-icons/boxes-icon.svelte";
interface Props {
svgTitle: string;
}
let { svgTitle }: Props = $props();
</script>
<div class="flex w-full flex-col items-center justify-center space-y-4">
<BoxesIcon size={48} strokeWidth={1} />
<p>"{svgTitle}" not found</p>
<div class="flex items-center justify-center space-x-2">
<a
target="_blank"
href={globals.requestSvgUrl}
class={buttonVariants({ variant: "outline" })}
>
<span>Request SVG</span>
<ArrowUpRight size={14} strokeWidth={1.5} />
</a>
<a
target="_blank"
href={globals.submitUrl}
class={buttonVariants({ variant: "outline" })}
>
<span>Submit SVG</span>
<ArrowUpRight size={14} strokeWidth={1.5} />
</a>
</div>
</div>
+2
View File
@@ -4,4 +4,6 @@ export const globals = {
twitterUrl: "https://x.com/pheralb_",
submitUrl:
"https://github.com/pheralb/svgl?tab=readme-ov-file#-getting-started",
requestSvgUrl:
"https://github.com/pheralb/svgl/issues/new?template=request-svg.yml",
};
+7 -2
View File
@@ -20,6 +20,7 @@
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
import PageHeader from "@/components/pageHeader.svelte";
import Button from "@/components/ui/button/button.svelte";
import SvgNotFound from "@/components/svgs/svgNotFound.svelte";
// SSR Data:
let { data }: PageProps = $props();
@@ -44,7 +45,8 @@
updateDisplaySvgs();
return;
}
filteredSvgs = searchSvgsWithFuse(filteredSvgs)
const baseData = sorted ? alphabeticallySorted : latestSorted;
filteredSvgs = searchSvgsWithFuse(baseData)
.search(searchTerm)
.map((result) => result.item);
updateDisplaySvgs();
@@ -122,12 +124,15 @@
<div class="mt-6 flex justify-center">
<Button variant="outline" size="lg" onclick={() => (showAll = true)}>
<span>Show All</span>
<span class="text-neutral-500 dark:text-neutral-700">
<span class="text-neutral-500 dark:text-neutral-500">
(+ {filteredSvgs.length - maxDisplay} SVGs)
</span>
<ChevronDownIcon size={16} strokeWidth={2} />
</Button>
</div>
{/if}
{#if filteredSvgs.length === 0}
<SvgNotFound svgTitle={searchTerm} />
{/if}
</Container>
</PageCard>
+6 -1
View File
@@ -19,6 +19,7 @@
import { Button, buttonVariants } from "@/components/ui/button";
import SortSvgs from "@/components/svgs/sortSvgs.svelte";
import { deleteParam } from "@/utils/searchParams";
import SvgNotFound from "@/components/svgs/svgNotFound.svelte";
// SSR Data:
let { data }: PageProps = $props();
@@ -42,7 +43,8 @@
updateDisplaySvgs();
return;
}
filteredSvgs = searchSvgsWithFuse(filteredSvgs)
const baseData = sorted ? data.alphabeticallySorted : data.latestSorted;
filteredSvgs = searchSvgsWithFuse(baseData)
.search(searchTerm)
.map((result) => result.item);
updateDisplaySvgs();
@@ -127,5 +129,8 @@
<SvgCard svgInfo={svg} />
{/each}
</Grid>
{#if filteredSvgs.length === 0}
<SvgNotFound svgTitle={searchTerm} />
{/if}
</Container>
</PageCard>