2025-03-03 18:40:41 +00:00
|
|
|
<script lang="ts">
|
2025-04-29 17:44:09 -04:00
|
|
|
import QRCode from 'qrcode';
|
2025-03-03 18:40:41 +00:00
|
|
|
import { t } from 'svelte-i18n';
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
value: string;
|
|
|
|
|
width: number;
|
|
|
|
|
alt?: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const { value, width, alt = $t('alt_text_qr_code') }: Props = $props();
|
|
|
|
|
|
2025-05-17 08:05:23 -05:00
|
|
|
let promise = $derived(QRCode.toDataURL(value, { margin: 0, width }));
|
2025-03-03 18:40:41 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div style="width: {width}px; height: {width}px">
|
|
|
|
|
{#await promise then url}
|
|
|
|
|
<img src={url} {alt} class="h-full w-full" />
|
|
|
|
|
{/await}
|
|
|
|
|
</div>
|