@thinkpixellab-public/px-vue 4.0.6 → 4.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,72 +1,31 @@
1
1
  <!--
2
- #VUE3 Todo
3
- -->
4
-
5
- <!--
6
- Creates a custom svg-based qr code.
2
+ Creates a custom qr code.
7
3
 
8
4
  Usage:
9
5
  <px-qr-code :content="http://thinkpixellab.com" />
10
6
 
11
7
  -->
12
8
  <template>
13
- <div :class="bem()" v-html="svg"></div>
9
+ <qrcode-vue
10
+ :class="bem()"
11
+ v-if="content"
12
+ :value="content"
13
+ :size="size"
14
+ role="img"
15
+ :aria-label="label"
16
+ ></qrcode-vue>
14
17
  </template>
15
18
 
16
19
  <script>
17
- import { toString as qrCodeToString } from 'qrcode';
18
- import PxBaseResize from '../bases/PxBaseResize.vue';
20
+ import QrcodeVue from 'qrcode.vue';
19
21
 
20
22
  export default {
21
23
  name: 'px-qr-code',
22
- mixins: [PxBaseResize],
24
+ components: { QrcodeVue },
23
25
  props: {
24
26
  content: { type: String, default: 'Hello' },
25
- foreground: { type: String, default: '#000000' },
26
- background: { type: String, default: '#FFFFFF' },
27
- padding: { type: Number, default: 0 },
28
- ecl: { type: String, default: 'L' },
29
- },
30
- data() {
31
- return { size: 0, svg: '' };
32
- },
33
- watch: {
34
- content() {
35
- this.updateSvg();
36
- },
37
- foreground() {
38
- this.updateSvg();
39
- },
40
- background() {
41
- this.updateSvg();
42
- },
43
- padding() {
44
- this.updateSvg();
45
- },
46
- },
47
- mounted() {
48
- this.updateSvg();
49
- },
50
- methods: {
51
- updateSvg() {
52
- qrCodeToString(
53
- this.content,
54
- {
55
- type: 'svg',
56
- margin: this.padding,
57
- color: {
58
- dark: this.foreground,
59
- light: this.background,
60
- },
61
- },
62
- (err, str) => {
63
- if (err) {
64
- console.warn('Error creating QR Code. \n' + err);
65
- }
66
- this.svg = str;
67
- }
68
- );
69
- },
27
+ label: { type: String },
28
+ size: { type: Number, default: 400 },
70
29
  },
71
30
  };
72
31
  </script>
@@ -75,8 +34,12 @@ export default {
75
34
  .px-qr-code {
76
35
  aspect-ratio: 1;
77
36
  width: 256px;
78
- svg {
79
- width: 100%;
37
+ canvas {
38
+ position: absolute;
39
+ top: 0;
40
+ left: 0;
41
+ width: 100% !important;
42
+ height: 100% !important;
80
43
  }
81
44
  }
82
45
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "4.0.6",
3
+ "version": "4.0.8",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "@thinkpixellab-public/vue-resize-directive": "^1.2.2",
21
21
  "body-scroll-lock": "^4.0.0-beta.0",
22
22
  "mitt": "^3.0.0",
23
- "qrcode": "^1.5.3",
23
+ "qrcode.vue": "^3.4.0",
24
24
  "throttle-debounce": "^5.0.0",
25
25
  "vue": "^3.3.4",
26
26
  "vue-inline-svg": "^3.1.0"