diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index d303b46..97604bc 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,26 +1,13 @@ @@ -35,16 +22,6 @@ {#if roster.saveStatus === 'saving'}Saving...{:else if roster.saveStatus === 'saved'}Saved{/if} - {#if roster.active} - - {#if copied} - - {:else} - - {/if} - - {/if} - import type { Character } from '$lib/types'; import { generateRecord } from '$lib/output'; + import { encodeCharacterURL } from '$lib/sharing'; import { species } from '$lib/data'; import OutputTab from './OutputTab.svelte'; @@ -21,10 +22,16 @@ let output = $derived( activeTab ? generateRecord(character.template, character.data, activeTab, species) : '' ); + + async function share() { + const encoded = encodeCharacterURL(character); + const url = `${window.location.origin}${window.location.pathname}#${encoded}`; + await navigator.clipboard.writeText(url); + } - + {#each tabs as tab} { activeTab = tab.type; }} @@ -38,5 +45,5 @@ {/each} - + diff --git a/src/lib/components/OutputTab.svelte b/src/lib/components/OutputTab.svelte index 5ea434a..bfb86ca 100644 --- a/src/lib/components/OutputTab.svelte +++ b/src/lib/components/OutputTab.svelte @@ -1,9 +1,10 @@ - + {wordCount} words - - {#if copied} - Copied - {:else} - Copy + + + {#if copied} + Copied + {:else} + Copy + {/if} + + {#if onShare} + + {#if shared} + Link Copied + {:else} + Share + {/if} + {/if} - + {output}
{output}