From 86a1b5fa8fd802363456afb5a4351585e78113d7 Mon Sep 17 00:00:00 2001 From: pheralb Date: Sat, 13 Jan 2024 12:22:36 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Fixed=20copy=20&=20download=20wo?= =?UTF-8?q?rdmark=20svg=20version.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/svgCard.svelte | 137 ++++++++++++++++++++++++---------- 1 file changed, 99 insertions(+), 38 deletions(-) diff --git a/src/components/svgCard.svelte b/src/components/svgCard.svelte index 871a628..f52b388 100644 --- a/src/components/svgCard.svelte +++ b/src/components/svgCard.svelte @@ -17,7 +17,7 @@ PackageIcon, PaintBucket, ChevronsRight, - CaseSensitive + Baseline } from 'lucide-svelte'; // Main Card: @@ -64,6 +64,19 @@ zip.file(`${svgInfo.title}.svg`, lightSvg); zip.file(`${svgInfo.title}.dark.svg`, darkSvg); + if (svgInfo.wordmark) { + if (typeof svgInfo.wordmark === 'string') { + downloadSvg(svgInfo.wordmark); + return; + } + + const lightWordmarkSvg = await getSvgContent(svgInfo.wordmark.light, false); + const darkWordmarkSvg = await getSvgContent(svgInfo.wordmark.dark, false); + + zip.file(`${svgInfo.title}.wordmark.svg`, lightWordmarkSvg); + zip.file(`${svgInfo.title}.wordmark.dark.svg`, darkWordmarkSvg); + } + zip.generateAsync({ type: 'blob' }).then((content) => { download(content, `${svgInfo.title}.zip`, 'application/zip'); }); @@ -82,14 +95,28 @@ if (isInFigma) { const content = (await getSvgContent(url, false)) as string; figmaCopyToClipboard(content); - } else { - try { - const clipboardItem = new ClipboardItem(data); - await navigator.clipboard.write([clipboardItem]); - } catch (error) { - const content = (await getSvgContent(url, false)) as string; - await navigator.clipboard.writeText(content); - } + } + + try { + const clipboardItem = new ClipboardItem(data); + await navigator.clipboard.write([clipboardItem]); + } catch (error) { + const content = (await getSvgContent(url, false)) as string; + await navigator.clipboard.writeText(content); + } + + if (isInFigma) { + toast.success('Ready to paste in Figma!', { + description: `${svgInfo.title} - ${svgInfo.category}` + }); + return; + } + + if (wordmarkSvg) { + toast.success('Copied wordmark SVG to clipboard!', { + description: `${svgInfo.title} - ${svgInfo.category}` + }); + return; } toast.success('Copied to clipboard!', { @@ -113,14 +140,18 @@ {#if wordmarkSvg == true} {svgInfo.title} {/if} - + {:else} + + const dark = document.documentElement.classList.contains('dark'); + + copyToClipboard( + typeof svgInfo.route !== 'string' + ? dark + ? svgInfo.route.dark + : svgInfo.route.light + : svgInfo.route + ); + }} + class="flex items-center space-x-2 rounded-md p-2 duration-100 hover:bg-neutral-200 dark:hover:bg-neutral-700/40" + > + + + {/if} {#if typeof svgInfo.route !== 'string'} @@ -235,7 +296,7 @@ }} > -

Light & Dark variants

+

Light & dark variants

{ wordmarkSvg = !wordmarkSvg; }} class="flex items-center space-x-2 rounded-md p-2 duration-100 hover:bg-neutral-200 dark:hover:bg-neutral-700/40" > - + {/if}