refactor(share): moves the share button into the right split, rather than the header
This commit is contained in:
parent
8875b70a14
commit
5e89d0e64f
3 changed files with 38 additions and 35 deletions
|
|
@ -1,26 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { Sun, Moon, Share2, Check } from 'lucide-svelte';
|
||||
import { Sun, Moon } from 'lucide-svelte';
|
||||
import { theme } from '$lib/theme.svelte';
|
||||
import { roster } from '$lib/state.svelte';
|
||||
import { presets } from '$lib/presets';
|
||||
import { encodeCharacterURL } from '$lib/sharing';
|
||||
import CharacterSwitcher from './CharacterSwitcher.svelte';
|
||||
|
||||
let copied = $state(false);
|
||||
|
||||
async function createCharacter() {
|
||||
await roster.create(presets[0]);
|
||||
}
|
||||
|
||||
async function share() {
|
||||
const char = roster.active;
|
||||
if (!char) return;
|
||||
const encoded = encodeCharacterURL(char);
|
||||
const url = `${window.location.origin}${window.location.pathname}#${encoded}`;
|
||||
await navigator.clipboard.writeText(url);
|
||||
copied = true;
|
||||
setTimeout(() => { copied = false; }, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="flex items-center gap-3 px-4 py-3 border-b shrink-0" style="border-color: var(--border); background: var(--bg-card);">
|
||||
|
|
@ -35,16 +22,6 @@
|
|||
{#if roster.saveStatus === 'saving'}Saving...{:else if roster.saveStatus === 'saved'}Saved{/if}
|
||||
</span>
|
||||
|
||||
{#if roster.active}
|
||||
<button onclick={share} class="p-1 rounded hover:opacity-80" title="Copy share link">
|
||||
{#if copied}
|
||||
<Check size={18} />
|
||||
{:else}
|
||||
<Share2 size={18} />
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
onclick={createCharacter}
|
||||
class="px-3 py-1 rounded text-sm border hover:opacity-80"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue