fix: update tool card component - route resolve issue

This commit is contained in:
2026-09-07 12:30:32 +05:00
parent 20e07fae85
commit 987f4535c8
4 changed files with 15 additions and 28 deletions
+3 -5
View File
@@ -6,17 +6,15 @@
interface Props { interface Props {
title: string; title: string;
href: string; id: string;
description?: string; description?: string;
index?: number; index?: number;
icon?: Component<{ size?: number; class?: string }>; icon?: Component<{ size?: number; class?: string }>;
} }
let { title, href, description, index, icon }: Props = $props(); let { title, id, description, index, icon }: Props = $props();
let normalizedHref = $derived(href === "#" ? "/" : href);
</script> </script>
<a class="tool-card" href={resolve(normalizedHref)}> <a class="tool-card" href={resolve("/preview/tools/[id]", { id })}>
{#if icon}<span class="tool-icon"><Icon {icon} size={19} /></span>{/if} {#if icon}<span class="tool-icon"><Icon {icon} size={19} /></span>{/if}
<span class="tool-copy"> <span class="tool-copy">
<strong>{title}</strong> <strong>{title}</strong>
+1 -1
View File
@@ -47,7 +47,7 @@
{#each results as tool (tool.id)} {#each results as tool (tool.id)}
<ToolCard <ToolCard
title={tool.title} title={tool.title}
href="/preview/tools/{tool.id}" id={tool.id}
description={tool.description} description={tool.description}
/> />
{/each} {/each}
+10 -21
View File
@@ -22,7 +22,10 @@
import IconButton from "$lib/components/kit/ui/IconButton.svelte"; import IconButton from "$lib/components/kit/ui/IconButton.svelte";
import Segmented from "$lib/components/kit/ui/Segmented.svelte"; import Segmented from "$lib/components/kit/ui/Segmented.svelte";
import Toggle from "$lib/components/kit/ui/Toggle.svelte"; import Toggle from "$lib/components/kit/ui/Toggle.svelte";
import { Download, ImageOff, Palette, Plus, Trash2 } from "@lucide/svelte"; import { Download, ImageOff, Plus, Trash2 } from "@lucide/svelte";
import { TOOLS } from "$lib/registry-new";
import { TOOL_ICONS } from "$lib/preview/tool-icons";
let mode = $state("preview"); let mode = $state("preview");
let radius = $state(8); let radius = $state(8);
@@ -32,23 +35,9 @@
let lossless = $state(true); let lossless = $state(true);
let animated = $state(false); let animated = $state(false);
const tools = [ const showcaseTools = TOOLS.filter((tool) =>
{ ["linear-gradient-png", "resize-png", "quantize-png"].includes(tool.id),
title: "Gradient", );
href: "#",
description: "Linear & radial gradients",
},
{
title: "Resize",
href: "#",
description: "Pixel-perfect scaling",
},
{
title: "Quantize",
href: "#",
description: "Reduce color depth",
},
];
</script> </script>
<div class="showcase"> <div class="showcase">
@@ -152,13 +141,13 @@
<Panel title="Tools" eyebrow="catalog"> <Panel title="Tools" eyebrow="catalog">
<div class="tool-grid"> <div class="tool-grid">
{#each tools as tool, i (tool.title)} {#each showcaseTools as tool, i (tool.id)}
<ToolCard <ToolCard
title={tool.title} title={tool.title}
href={tool.href} id={tool.id}
description={tool.description} description={tool.description}
index={i + 1} index={i + 1}
icon={Palette} icon={TOOL_ICONS[tool.id]}
/> />
{/each} {/each}
</div> </div>
@@ -33,7 +33,7 @@
{#each group.tools as tool, i (tool.id)} {#each group.tools as tool, i (tool.id)}
<ToolCard <ToolCard
title={tool.title} title={tool.title}
href={`/preview/tools/${tool.id}`} id={tool.id}
description={tool.description} description={tool.description}
index={i + 1} index={i + 1}
icon={TOOL_ICONS[tool.id]} icon={TOOL_ICONS[tool.id]}