| 
									
										
										
										
											2023-05-11 17:29:25 +02:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2023-12-01 15:23:28 +01:00
										 |  |  |   import Share from "../../assets/svg/Share.svelte" | 
					
						
							| 
									
										
										
										
											2023-12-14 18:25:35 +01:00
										 |  |  |   import { ariaLabel } from "../../Utils/ariaLabel" | 
					
						
							|  |  |  |   import Translations from "../i18n/Translations" | 
					
						
							| 
									
										
										
										
											2023-05-11 17:29:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   export let generateShareData: () => { | 
					
						
							| 
									
										
										
										
											2023-05-11 17:29:25 +02:00
										 |  |  |     text: string | 
					
						
							|  |  |  |     title: string | 
					
						
							|  |  |  |     url: string | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-12-25 23:55:52 +01:00
										 |  |  |   export let text: string | 
					
						
							|  |  |  |   let isIcon = text === undefined || text === "" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   function share() { | 
					
						
							| 
									
										
										
										
											2023-05-11 17:29:25 +02:00
										 |  |  |     if (!navigator.share) { | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |       console.log("web share not supported") | 
					
						
							|  |  |  |       return | 
					
						
							| 
									
										
										
										
											2023-05-11 17:29:25 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     navigator | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |       .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-12-25 23:55:52 +01:00
										 |  |  | {#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} |