blob: d5dbfc417cdac434ffb8b14b037cdc19710f6958 (
plain) (
blame)
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
|
<script lang="ts">
import { onMount } from "svelte";
import { browser } from "$app/environment";
let { icon = "", text }: any = $props();
let qr = $state();
let screenfull;
onMount(async () => {
if (!browser) return;
screenfull = (await import("screenfull")).default;
});
let src = $derived.by(() => {
let url = `/qr/${encodeURIComponent(text)}`;
if (icon) url += `/${icon}`;
else url += "/raw";
return url;
});
</script>
<div
class="w-72 sm:w-80 mx-auto cursor-pointer"
bind:this={qr}
onclick={() => screenfull?.toggle?.(qr)}
onkeydown={(e) => (e.key === "Enter" || e.key === " ") && screenfull?.toggle?.(qr)}
role="button"
tabindex="0"
aria-label="Toggle fullscreen QR"
>
<img {src} class="mx-auto" alt="QR Code" />
</div>
|