diff --git a/components/dashboard/links/QRCode.vue b/components/dashboard/links/QRCode.vue index 437561e..3ef8ba8 100644 --- a/components/dashboard/links/QRCode.vue +++ b/components/dashboard/links/QRCode.vue @@ -2,6 +2,7 @@ import { Button } from '#components' import { Download } from 'lucide-vue-next' import QRCodeStyling from 'qr-code-styling' +import { ref, watch } from 'vue' const props = defineProps({ data: { @@ -13,6 +14,7 @@ const props = defineProps({ default: '', }, }) +const color = ref('#000000') const options = { width: 256, height: 256, @@ -70,6 +72,18 @@ const options = { const qrCode = new QRCodeStyling(options) const qrCodeEl = ref(null) +function updateColor(newColor) { + qrCode.update({ + dotsOptions: { type: 'dots', color: newColor, gradient: null }, + cornersSquareOptions: { type: 'extra-rounded', color: newColor }, + cornersDotOptions: { type: 'dot', color: newColor }, + }) +} + +watch(color, (newColor) => { + updateColor(newColor) +}) + function downloadQRCode() { const slug = props.data.split('/').pop() qrCode.download({ @@ -89,9 +103,24 @@ onMounted(() => { ref="qrCodeEl" :data-text="data" /> - +