aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Qr.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-08-31 13:50:03 -0700
committerAdam Soltys <[email protected]>2022-08-31 13:50:03 -0700
commitbd1e9ee212541c8f6236bea6256cad082b2ea35a (patch)
tree023bb3b21046add5fe231724aa178ad285d942fe /src/components/Qr.svelte
parentfe2e2b7760d82ba25676cd96035379c6570b7cb0 (diff)
downloadcoinos-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.svelte53
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>