cryptgeon/packages/frontend/src/lib/ui/Canvas.svelte

43 lines
686 B
Svelte
Raw Normal View History

2023-01-04 19:40:37 +01:00
<script lang="ts">
// @ts-ignore
2023-01-04 19:40:37 +01:00
import QR from 'qrious'
2023-01-04 19:45:25 +01:00
import { t } from 'svelte-intl-precompile'
2023-01-04 19:40:37 +01:00
import { getCSSVariable } from '$lib/utils'
export let value: string
let canvas: HTMLCanvasElement
$: {
new QR({
value,
level: 'Q',
size: 800,
background: getCSSVariable('--ui-bg-0'),
foreground: getCSSVariable('--ui-text-0'),
element: canvas,
})
}
</script>
2023-01-04 19:45:25 +01:00
<small>{$t('common.qr_code')}</small>
2023-01-04 19:40:37 +01:00
<div>
<canvas bind:this={canvas} />
</div>
<style>
div {
padding: 0.5rem;
width: fit-content;
border: 2px solid var(--ui-bg-1);
background-color: var(--ui-bg-0);
margin-top: 0.125rem;
}
canvas {
width: 100%;
height: auto;
}
</style>