blob: 7b822fc0aacaf0945c447a7f2be45482cbbf0aa3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
<script lang="ts" context="module">
export function isShareSupported() {
return (
typeof navigator !== 'undefined' &&
typeof navigator.share === 'function'
);
}
</script>
<script lang="ts">
import SFSymbol from '~/components/SFSymbol.svelte';
import { getI18n } from '~/stores/i18n';
export let url: string;
export let withLabel: boolean = false;
const i18n = getI18n();
$: isShareSheetOpen = false;
async function handleShareClick() {
isShareSheetOpen = !isShareSheetOpen;
try {
await navigator.share({ url });
isShareSheetOpen = false;
} catch {
isShareSheetOpen = false;
}
}
</script>
<button
on:click={handleShareClick}
aria-label={$i18n.t('ASE.Web.AppStore.Share.Button.AccessibilityValue')}
class:active={isShareSheetOpen}
class:with-label={withLabel}
>
<SFSymbol name="square.and.arrow.up" ariaHidden={true} />
{#if withLabel}
{$i18n.t('ASE.Web.AppStore.Share.Button.Value')}
{/if}
</button>
<style lang="scss">
button {
position: relative;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: var(--share-arrow-size, 32px);
height: var(--share-arrow-size, 32px);
border-radius: var(--share-arrow-size, 32px);
background: var(--systemQuaternary-onDark);
transition: background-color 210ms ease-out;
mix-blend-mode: plus-lighter;
}
button.with-label {
display: flex;
align-items: center;
width: auto;
padding: 0 16px;
gap: 8px;
font: var(--body-emphasized);
:global(svg) {
height: 16px;
width: auto;
top: -2px;
position: relative;
}
}
button.active,
button:hover {
// stylelint-disable color-function-notation
background-color: rgb(from var(--systemTertiary-onDark) r g b/.13);
// stylelint-enable color-function-notation
}
button :global(svg) {
width: 37%;
fill: var(--systemPrimary-onDark);
overflow: visible;
}
</style>
|