diff options
| author | Adam Soltys <[email protected]> | 2022-08-31 13:50:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-31 13:50:03 -0700 |
| commit | bd1e9ee212541c8f6236bea6256cad082b2ea35a (patch) | |
| tree | 023bb3b21046add5fe231724aa178ad285d942fe /src/components/Qr.svelte | |
| parent | fe2e2b7760d82ba25676cd96035379c6570b7cb0 (diff) | |
| download | coinos-ui-bd1e9ee212541c8f6236bea6256cad082b2ea35a.tar.gz coinos-ui-bd1e9ee212541c8f6236bea6256cad082b2ea35a.zip | |
hook up 2fa setting
Diffstat (limited to 'src/components/Qr.svelte')
| -rw-r--r-- | src/components/Qr.svelte | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/components/Qr.svelte b/src/components/Qr.svelte new file mode 100644 index 00000000..fcdc6c7d --- /dev/null +++ b/src/components/Qr.svelte @@ -0,0 +1,53 @@ +<script> + import { browser } from "$app/env"; + import { onMount } from 'svelte'; + import { copy } from '$lib/utils'; + + export let image, text; + + let qr; + + onMount(async () => { + if (!(browser && text)) return; + let { default: QRCodeStyling } = await import('qr-code-styling'); + + const qrCode = new QRCodeStyling({ + width: window.screen.width < 640 ? 250 : 300, + type: 'canvas', + data: text, + backgroundOptions: { + color: 'rgba(0, 0, 0, 0)' + }, + dotsOptions: { + type: 'rounded' + }, + imageOptions: { + hideBackgroundDots: false + } + }); + + while (qr.firstChild) qr.removeChild(qr.lastChild); + qrCode.append(qr); + }); +</script> + +<div bind:this={qr} on:click={() => copy(text)} /> + +<style> + div { + @apply + px-5 + md:px-0 + w-[292px] + h-[302px] + md:w-[300px] + md:h-[300px] + rounded-3xl + block + md:flex + justify-center + items-center + cursor-pointer + mx-auto; + } +</style> |
