feat: add the ability to print qrcodes to <lnbits-qrcode> component (#3664)
This commit is contained in:
parent
b6e111b21c
commit
c7297d2e77
4 changed files with 51 additions and 2 deletions
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -13,6 +13,10 @@ window.app.component('lnbits-qrcode', {
|
|||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
print: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showButtons: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
|
|
@ -41,6 +45,41 @@ window.app.component('lnbits-qrcode', {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
printQrCode() {
|
||||
const svg = this.$refs.qrCode.$el.outerHTML
|
||||
const printWindow = window.open('', '_blank')
|
||||
printWindow.document.write(`
|
||||
<html>
|
||||
<head>
|
||||
<title>Print QR Code</title>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
img {
|
||||
position: absolute;
|
||||
max-width: 51px;
|
||||
width: 14%;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
padding: -1.2rem;
|
||||
border-radius: -1.2rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>${svg}<img src="${this.logo}"></body>
|
||||
</html>
|
||||
`)
|
||||
printWindow.document.close()
|
||||
printWindow.focus()
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
},
|
||||
clickQrCode(event) {
|
||||
if (this.href === '') {
|
||||
this.utils.copyText(this.value)
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ include('components/lnbits-error.vue') %}
|
|||
<q-tab name="bech32" icon="qr_code" label="bech32"></q-tab>
|
||||
<q-tab name="lud17" icon="link" label="url (lud17)"></q-tab>
|
||||
</q-tabs>
|
||||
<lnbits-qrcode :value="lnurl" nfc="true"></lnbits-qrcode>
|
||||
<lnbits-qrcode :value="lnurl" nfc="true" print="true"></lnbits-qrcode>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,16 @@
|
|||
>
|
||||
<q-tooltip>Write NFC Tag</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-if="print"
|
||||
flat
|
||||
dense
|
||||
class="text-grey"
|
||||
@click="printQrCode()"
|
||||
icon="print"
|
||||
>
|
||||
<q-tooltip>Print</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn flat dense class="text-grey" icon="download" @click="downloadSVG">
|
||||
<q-tooltip>Download SVG</q-tooltip>
|
||||
</q-btn>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue