Improve share functionality

This commit is contained in:
Pieter Vander Vennet 2023-12-25 23:55:52 +01:00
parent df6e47faa8
commit 6cd3c15544
6 changed files with 68 additions and 18 deletions

View file

@ -1,6 +1,4 @@
<script lang="ts">
import ToSvelte from "./ToSvelte.svelte"
import Svg from "../../Svg"
import Share from "../../assets/svg/Share.svelte"
import { ariaLabel } from "../../Utils/ariaLabel"
import Translations from "../i18n/Translations"
@ -10,6 +8,9 @@
title: string
url: string
}
export let text: string
let isIcon = text === undefined || text === ""
function share() {
if (!navigator.share) {
console.log("web share not supported")
@ -26,8 +27,16 @@
}
</script>
<button on:click={share} class="soft no-image-background m-0 h-8 w-8 p-0" use:ariaLabel={Translations.t.general.share}>
<slot name="content">
<Share class="h-7 w-7 p-1" />
</slot>
</button>
{#if isIcon}
<button on:click={share} class="soft no-image-background m-0 h-8 w-8 p-0"
use:ariaLabel={Translations.t.general.share}>
<slot name="content">
<Share class="h-7 w-7 p-1" />
</slot>
</button>
{:else}
<button on:click={share}>
<Share class="h-8 w-8 pr-2" />
{text}
</button>
{/if}