diff --git a/src/components/Actions.svelte b/src/components/Actions.svelte index 2be88d4..1e90cb8 100644 --- a/src/components/Actions.svelte +++ b/src/components/Actions.svelte @@ -1,4 +1,7 @@ - Copy URL + Copy Link {#if logo.format === 'SVG'} {#if showCopyMenu} - + + + + + + Copy SVG Source + - Copy PNG Link + + Copy PNG Link - Copy JPG Link + + Copy JPG Link {/if} @@ -215,27 +243,27 @@ {#if showDownloadMenu} - Download PNG + + Download PNG - Download JPG + + Download JPG {/if} {/if} -{#if showNotification} - - {notificationText} - -{/if} -{#if showNotification} - - {notificationText} - -{/if} + + diff --git a/src/components/List.svelte b/src/components/List.svelte index 0e3b3bb..ccbb1e1 100644 --- a/src/components/List.svelte +++ b/src/components/List.svelte @@ -1,6 +1,7 @@ + +{#if show} + + {text} + +{/if} + + diff --git a/src/utils/svgSource.js b/src/utils/svgSource.js new file mode 100644 index 0000000..79bec8e --- /dev/null +++ b/src/utils/svgSource.js @@ -0,0 +1,35 @@ +/** + * Fetches the SVG source code from a file path + * + * @param {string} path - Path to the SVG file + * @returns {Promise} - The SVG source code + */ +export async function fetchSvgSource(path) { + try { + const response = await fetch(path); + if (!response.ok) { + throw new Error(`Failed to fetch SVG: ${response.status}`); + } + return await response.text(); + } catch (error) { + console.error('Error fetching SVG source:', error); + throw error; + } +} + +/** + * Copy SVG source to clipboard + * + * @param {string} path - Path to the SVG file + * @returns {Promise} - True if successful, false otherwise + */ +export async function copySvgSource(path) { + try { + const svgSource = await fetchSvgSource(path); + await navigator.clipboard.writeText(svgSource); + return true; + } catch (error) { + console.error('Error copying SVG source:', error); + return false; + } +}