From 83dd8245a8789de70d772ef259af723401b4b7ac Mon Sep 17 00:00:00 2001 From: sHa Date: Wed, 18 Jun 2025 16:49:05 +0300 Subject: [PATCH] fix: Update collection label retrieval to support titles and improve SVG error handling --- src/components/Header.svelte | 8 +- src/components/InlineSvg.svelte | 191 +++++++++++++++++--------------- 2 files changed, 106 insertions(+), 93 deletions(-) diff --git a/src/components/Header.svelte b/src/components/Header.svelte index d760810..1955620 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -45,7 +45,8 @@ dropdownOpen = false; } - $: currentLabel = (collections.find(c => c.name === collection)?.label || "Logo Gallery").replace(/s$/, ""); + $: currentCollectionObj = collections.find(c => c.name === collection); + $: currentLabel = (currentCollectionObj?.title || currentCollectionObj?.label || "Logo Gallery").replace(/s$/, "");
@@ -55,7 +56,7 @@ Logo Gallery icon {#if dropdownOpen} {/if} @@ -107,6 +108,7 @@ {getTagObj} {compactMode} {setCompactMode} + collection={currentCollectionObj} /> `; + svgSource = svgHtml; + return; + } + let text = await res.text(); + if (!color) { + // No user-selected color, add currentColor to ensure theme colors are applied + const parser = new DOMParser(); + const doc = parser.parseFromString(text, "image/svg+xml"); + const svg = doc.documentElement; + + // Set currentColor on SVG element if no fill is specified + if (!svg.hasAttribute("fill")) { + svg.setAttribute("fill", "currentColor"); + } + + svgHtml = doc.documentElement.outerHTML; + return; + } + // Parse and update color only if user selected const parser = new DOMParser(); const doc = parser.parseFromString(text, "image/svg+xml"); - const svg = doc.documentElement; - - // Set currentColor on SVG element if no fill is specified - if (!svg.hasAttribute("fill")) { - svg.setAttribute("fill", "currentColor"); - } - - svgHtml = doc.documentElement.outerHTML; - return; - } - // Parse and update color only if user selected - const parser = new DOMParser(); - const doc = parser.parseFromString(text, "image/svg+xml"); - // 1. Parse