mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2025-12-16 23:54:58 +00:00
qr code
This commit is contained in:
41
packages/frontend/src/lib/ui/Canvas.svelte
Normal file
41
packages/frontend/src/lib/ui/Canvas.svelte
Normal file
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
import QR from 'qrious'
|
||||
|
||||
import { getCSSVariable } from '$lib/utils'
|
||||
|
||||
export let label: string
|
||||
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>
|
||||
|
||||
<small>{label}</small>
|
||||
<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>
|
||||
Reference in New Issue
Block a user