mapcomplete/UI/Base/ShareButton.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
704 B
Svelte
Raw Normal View History

2023-05-11 17:29:25 +02:00
<script lang="ts">
import ToSvelte from "./ToSvelte.svelte"
import Svg from "../../Svg"
2023-05-11 17:29:25 +02:00
export let generateShareData: () => {
2023-05-11 17:29:25 +02:00
text: string
title: string
url: string
}
function share() {
2023-05-11 17:29:25 +02:00
if (!navigator.share) {
console.log("web share not supported")
return
2023-05-11 17:29:25 +02:00
}
navigator
.share(generateShareData())
.then(() => {
console.log("Thanks for sharing!")
})
.catch((err) => {
console.log(`Couldn't share because of`, err.message)
})
}
2023-05-11 17:29:25 +02:00
</script>
2023-06-14 20:44:01 +02:00
<button on:click={share} class="secondary m-0 h-8 w-8 p-0">
<slot name="content">
<ToSvelte construct={Svg.share_svg().SetClass("w-7 h-7 p-1")} />
</slot>
2023-05-11 17:29:25 +02:00
</button>