mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
✨ Improve `SVG not found` component with category context and update search placeholder
This commit is contained in:
@@ -2,20 +2,40 @@
|
|||||||
import { globals } from "@/globals";
|
import { globals } from "@/globals";
|
||||||
|
|
||||||
import { buttonVariants } from "@/components/ui/button";
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
|
import SearchIcon from "@lucide/svelte/icons/search";
|
||||||
import ArrowUpRight from "@lucide/svelte/icons/arrow-up-right";
|
import ArrowUpRight from "@lucide/svelte/icons/arrow-up-right";
|
||||||
import BoxesIcon from "@/components/ui/moving-icons/boxes-icon.svelte";
|
import BoxesIcon from "@/components/ui/moving-icons/boxes-icon.svelte";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
svgTitle: string;
|
svgTitle: string;
|
||||||
|
category?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { svgTitle }: Props = $props();
|
let { svgTitle, category }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex w-full flex-col items-center justify-center space-y-4">
|
<div class="flex w-full flex-col items-center justify-center space-y-4">
|
||||||
<BoxesIcon size={48} strokeWidth={1} />
|
<BoxesIcon size={48} strokeWidth={1} />
|
||||||
<p>"{svgTitle}" not found</p>
|
<h2 class="text-xl font-semibold">SVG not found</h2>
|
||||||
|
{#if category}
|
||||||
|
<p class="text-neutral-600 dark:text-neutral-400">
|
||||||
|
"{svgTitle}" not found in "{category}" category
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<p class="text-neutral-600 dark:text-neutral-400">
|
||||||
|
"{svgTitle}" not found
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
<div class="flex items-center justify-center space-x-2">
|
<div class="flex items-center justify-center space-x-2">
|
||||||
|
{#if category}
|
||||||
|
<a
|
||||||
|
href={`/?search=${svgTitle}`}
|
||||||
|
class={buttonVariants({ variant: "outline" })}
|
||||||
|
>
|
||||||
|
<SearchIcon size={14} strokeWidth={1.5} />
|
||||||
|
<span>Search globally</span>
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={globals.requestSvgUrl}
|
href={globals.requestSvgUrl}
|
||||||
|
|||||||
+21
-3
@@ -18,6 +18,7 @@
|
|||||||
import PageCard from "@/components/pageCard.svelte";
|
import PageCard from "@/components/pageCard.svelte";
|
||||||
import FolderIcon from "@lucide/svelte/icons/folder";
|
import FolderIcon from "@lucide/svelte/icons/folder";
|
||||||
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
|
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
|
||||||
|
import ChevronUpIcon from "@lucide/svelte/icons/chevron-up";
|
||||||
import PageHeader from "@/components/pageHeader.svelte";
|
import PageHeader from "@/components/pageHeader.svelte";
|
||||||
import Button from "@/components/ui/button/button.svelte";
|
import Button from "@/components/ui/button/button.svelte";
|
||||||
import SvgNotFound from "@/components/svgs/svgNotFound.svelte";
|
import SvgNotFound from "@/components/svgs/svgNotFound.svelte";
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
<SortSvgs
|
<SortSvgs
|
||||||
className={cn(filteredSvgs.length === 0 && "hidden")}
|
className={cn(filteredSvgs.length === 0 && "hidden")}
|
||||||
isSorted={sorted}
|
isSorted={sorted}
|
||||||
@@ -113,6 +115,17 @@
|
|||||||
searchSvgs();
|
searchSvgs();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{#if showAll && filteredSvgs.length > maxDisplay}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
class="px-2.5"
|
||||||
|
onclick={() => (showAll = false)}
|
||||||
|
>
|
||||||
|
<span>Show Less</span>
|
||||||
|
<ChevronUpIcon size={16} strokeWidth={2} />
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<Container className="my-6">
|
<Container className="my-6">
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -120,11 +133,16 @@
|
|||||||
<SvgCard svgInfo={svg} />
|
<SvgCard svgInfo={svg} />
|
||||||
{/each}
|
{/each}
|
||||||
</Grid>
|
</Grid>
|
||||||
{#if showAll === false && filteredSvgs.length > maxDisplay}
|
{#if !showAll && filteredSvgs.length > maxDisplay}
|
||||||
<div class="mt-6 flex justify-center">
|
<div class="mt-6 flex justify-center">
|
||||||
<Button variant="outline" size="lg" onclick={() => (showAll = true)}>
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="lg"
|
||||||
|
class="px-2.5"
|
||||||
|
onclick={() => (showAll = true)}
|
||||||
|
>
|
||||||
<span>Show All</span>
|
<span>Show All</span>
|
||||||
<span class="text-neutral-500 dark:text-neutral-500">
|
<span class="text-neutral-600 dark:text-neutral-400">
|
||||||
(+ {filteredSvgs.length - maxDisplay} SVGs)
|
(+ {filteredSvgs.length - maxDisplay} SVGs)
|
||||||
</span>
|
</span>
|
||||||
<ChevronDownIcon size={16} strokeWidth={2} />
|
<ChevronDownIcon size={16} strokeWidth={2} />
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
<Search
|
<Search
|
||||||
searchValue={searchTerm}
|
searchValue={searchTerm}
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
placeholder="Search..."
|
placeholder={`Search ${directoryData.category}'s SVGs...`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageCard>
|
<PageCard>
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</Grid>
|
</Grid>
|
||||||
{#if filteredSvgs.length === 0}
|
{#if filteredSvgs.length === 0}
|
||||||
<SvgNotFound svgTitle={searchTerm} />
|
<SvgNotFound svgTitle={searchTerm} category={directoryData.category} />
|
||||||
{/if}
|
{/if}
|
||||||
</Container>
|
</Container>
|
||||||
</PageCard>
|
</PageCard>
|
||||||
|
|||||||
Reference in New Issue
Block a user