@liquid-js/qr-code-styling 1.6.1 → 1.6.2
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.
- package/LICENSE +21 -21
- package/README.md +226 -226
- package/package.json +81 -81
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Denys Kozak
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Denys Kozak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,226 +1,226 @@
|
|
|
1
|
-
# QR Code Styling
|
|
2
|
-
[](https://www.npmjs.org/package/qr-code-styling)
|
|
3
|
-
|
|
4
|
-
JavaScript library for generating QR codes with a logo and styling.
|
|
5
|
-
|
|
6
|
-
Try it here https://qr-code-styling.com
|
|
7
|
-
|
|
8
|
-
If you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.
|
|
9
|
-
### Examples
|
|
10
|
-
<p float="left">
|
|
11
|
-
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/facebook_example_new.png" width="240" />
|
|
12
|
-
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/qr_code_example.png" width="240" />
|
|
13
|
-
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/telegram_example_new.png" width="240" />
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
### Installation
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
npm install qr-code-styling
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Usage
|
|
23
|
-
|
|
24
|
-
```HTML
|
|
25
|
-
<!DOCTYPE html>
|
|
26
|
-
<html lang="en">
|
|
27
|
-
<head>
|
|
28
|
-
<meta charset="UTF-8">
|
|
29
|
-
<title>QR Code Styling</title>
|
|
30
|
-
<script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js"></script>
|
|
31
|
-
</head>
|
|
32
|
-
<body>
|
|
33
|
-
<div id="canvas"></div>
|
|
34
|
-
<script type="text/javascript">
|
|
35
|
-
|
|
36
|
-
const qrCode = new QRCodeStyling.QRCodeStyling({
|
|
37
|
-
data: "https://www.facebook.com/",
|
|
38
|
-
image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
|
|
39
|
-
dotsOptions: {
|
|
40
|
-
color: "#4267b2",
|
|
41
|
-
type: "rounded"
|
|
42
|
-
},
|
|
43
|
-
backgroundOptions: {
|
|
44
|
-
color: "#e9ebee",
|
|
45
|
-
},
|
|
46
|
-
imageOptions: {
|
|
47
|
-
crossOrigin: "anonymous",
|
|
48
|
-
margin: 1
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
qrCode.append(document.getElementById("canvas"));
|
|
53
|
-
QRCodeStyling.browserUtils.download(qrCode);
|
|
54
|
-
</script>
|
|
55
|
-
</body>
|
|
56
|
-
</html>
|
|
57
|
-
```
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
[**React example (Codesandbox)**](https://codesandbox.io/s/qr-code-styling-react-example-l8rwl?file=/src/App.js)
|
|
61
|
-
|
|
62
|
-
[**Angular example (Codesandbox)**](https://codesandbox.io/s/agitated-panini-tpgb2?file=/src/app/app.component.ts)
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
[**React example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/react)
|
|
67
|
-
|
|
68
|
-
[**Angular example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/angular)
|
|
69
|
-
|
|
70
|
-
[**Vue example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/vue)
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
### API Documentation
|
|
75
|
-
|
|
76
|
-
#### QRCodeStyling instance
|
|
77
|
-
`new QRCodeStyling(options) => QRCodeStyling`
|
|
78
|
-
|
|
79
|
-
Param |Type |Description
|
|
80
|
-
-------|------|------------
|
|
81
|
-
options|object|Init object
|
|
82
|
-
|
|
83
|
-
`options` structure
|
|
84
|
-
|
|
85
|
-
Property |Type |Default Value|Description
|
|
86
|
-
-----------------------|-------------------------|-------------|-----------------------------------------------------
|
|
87
|
-
data |string | |The date will be encoded to the QR code
|
|
88
|
-
image |string | |The image will be copied to the center of the QR code
|
|
89
|
-
qrOptions |object | |Options will be passed to `qrcode-generator` lib
|
|
90
|
-
imageOptions |object | |Specific image options, details see below
|
|
91
|
-
dotsOptions |object | |Dots styling options
|
|
92
|
-
cornersSquareOptions |object | |Square in the corners styling options
|
|
93
|
-
cornersDotOptionsHelper|object | |Dots in the corners styling options
|
|
94
|
-
backgroundOptions |object | |QR background styling options
|
|
95
|
-
|
|
96
|
-
`options.qrOptions` structure
|
|
97
|
-
|
|
98
|
-
Property |Type |Default Value
|
|
99
|
-
--------------------|--------------------------------------------------|-------------
|
|
100
|
-
typeNumber |number (`0 - 40`) |`0`
|
|
101
|
-
mode |string (`'Numeric' 'Alphanumeric' 'Byte' 'Kanji'`)|
|
|
102
|
-
errorCorrectionLevel|string (`'L' 'M' 'Q' 'H'`) |`'Q'`
|
|
103
|
-
|
|
104
|
-
`options.imageOptions` structure
|
|
105
|
-
|
|
106
|
-
Property |Type |Default Value|Description
|
|
107
|
-
------------------|---------------------------------------|-------------|------------------------------------------------------------------------------
|
|
108
|
-
hideBackgroundDots|boolean |`true` |Hide all dots covered by the image
|
|
109
|
-
imageSize |number |`0.4` |Coefficient of the image size. Not recommended to use ove 0.5. Lower is better
|
|
110
|
-
margin |number |`0` |Margin of the image in blocks
|
|
111
|
-
crossOrigin |string(`'anonymous' 'use-credentials'`)| |Set "anonymous" if you want to download QR code from other origins.
|
|
112
|
-
|
|
113
|
-
`options.dotsOptions` structure
|
|
114
|
-
|
|
115
|
-
Property|Type |Default Value|Description
|
|
116
|
-
--------|------------------------------------------------------------------------------|-------------|-------------------
|
|
117
|
-
color |string |`'#000'` |Color of QR dots
|
|
118
|
-
gradient|object | |Gradient of QR dots
|
|
119
|
-
type |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded'`)|`'square'` |Style of QR dots
|
|
120
|
-
|
|
121
|
-
`options.backgroundOptions` structure
|
|
122
|
-
|
|
123
|
-
Property|Type |Default Value
|
|
124
|
-
--------|------|-------------
|
|
125
|
-
color |string|`'#fff'`
|
|
126
|
-
gradient|object|
|
|
127
|
-
|
|
128
|
-
`options.cornersSquareOptions` structure
|
|
129
|
-
|
|
130
|
-
Property|Type |Default Value|Description
|
|
131
|
-
--------|-----------------------------------------|-------------|-----------------
|
|
132
|
-
color |string | |Color of Corners Square
|
|
133
|
-
gradient|object | |Gradient of Corners Square
|
|
134
|
-
type |string (`'dot' 'square' 'extra-rounded'`)| |Style of Corners Square
|
|
135
|
-
|
|
136
|
-
`options.cornersDotOptions` structure
|
|
137
|
-
|
|
138
|
-
Property|Type |Default Value|Description
|
|
139
|
-
--------|-------------------------|-------------|-----------------
|
|
140
|
-
color |string | |Color of Corners Dot
|
|
141
|
-
gradient|object | |Gradient of Corners Dot
|
|
142
|
-
type |string (`'dot' 'square'`)| |Style of Corners Dot
|
|
143
|
-
|
|
144
|
-
Gradient structure
|
|
145
|
-
|
|
146
|
-
`options.dotsOptions.gradient`
|
|
147
|
-
|
|
148
|
-
`options.backgroundOptions.gradient`
|
|
149
|
-
|
|
150
|
-
`options.cornersSquareOptions.gradient`
|
|
151
|
-
|
|
152
|
-
`options.cornersDotOptions.gradient`
|
|
153
|
-
|
|
154
|
-
Property |Type |Default Value|Description
|
|
155
|
-
----------|----------------------------|-------------|---------------------------------------------------------
|
|
156
|
-
type |string (`'linear' 'radial'`)|"linear" |Type of gradient spread
|
|
157
|
-
rotation |number |0 |Rotation of gradient in radians (Math.PI === 180 degrees)
|
|
158
|
-
colorStops|array of objects | |Gradient colors. Example `[{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }]`
|
|
159
|
-
|
|
160
|
-
Gradient colorStops structure
|
|
161
|
-
|
|
162
|
-
`options.dotsOptions.gradient.colorStops[]`
|
|
163
|
-
|
|
164
|
-
`options.backgroundOptions.gradient.colorStops[]`
|
|
165
|
-
|
|
166
|
-
`options.cornersSquareOptions.gradient.colorStops[]`
|
|
167
|
-
|
|
168
|
-
`options.cornersDotOptions.gradient.colorStops[]`
|
|
169
|
-
|
|
170
|
-
Property|Type |Default Value|Description
|
|
171
|
-
--------|----------------|-------------|-----------------------------------
|
|
172
|
-
offset |number (`0 - 1`)| |Position of color in gradient range
|
|
173
|
-
color |string | |Color of stop in gradient range
|
|
174
|
-
|
|
175
|
-
#### QRCodeStyling methods
|
|
176
|
-
`QRCodeStyling.append(container) => void`
|
|
177
|
-
|
|
178
|
-
Param |Type |Description
|
|
179
|
-
---------|-----------|-----------
|
|
180
|
-
container|DOM element|This container will be used for appending of the QR code
|
|
181
|
-
|
|
182
|
-
`QRCodeStyling.serialize() => Promise<string>`
|
|
183
|
-
|
|
184
|
-
`QRCodeStyling.update(options) => void`
|
|
185
|
-
|
|
186
|
-
Param |Type |Description
|
|
187
|
-
-------|------|--------------------------------------
|
|
188
|
-
options|object|The same options as for initialization
|
|
189
|
-
|
|
190
|
-
`QRCodeStyling.applyExtension(extension) => void`
|
|
191
|
-
|
|
192
|
-
Param |Type |Description
|
|
193
|
-
---------|----------------------|------------------------------------------------------------------------------------------
|
|
194
|
-
extension|(svg, options) => void|Extension is a function that takes svg and previously applied options and modifies an svg
|
|
195
|
-
|
|
196
|
-
`applyExtension` example
|
|
197
|
-
|
|
198
|
-
```JS
|
|
199
|
-
const extension = (svg, options) => {
|
|
200
|
-
const { width, height } = options;
|
|
201
|
-
const size = Math.min(width, height);
|
|
202
|
-
const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
203
|
-
const borderAttributes = {
|
|
204
|
-
"fill": "none",
|
|
205
|
-
"x": (width - size + 40) / 2,
|
|
206
|
-
"y": (height - size + 40) / 2,
|
|
207
|
-
"width": size - 40,
|
|
208
|
-
"height": size - 40,
|
|
209
|
-
"stroke": 'black',
|
|
210
|
-
"stroke-width": 40,
|
|
211
|
-
"rx": 100,
|
|
212
|
-
};
|
|
213
|
-
Object.keys(borderAttributes).forEach(attribute => {
|
|
214
|
-
border.setAttribute(attribute, borderAttributes[attribute]);
|
|
215
|
-
});
|
|
216
|
-
svg.appendChild(border);
|
|
217
|
-
};
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
`QRCodeStyling.deleteExtension() => void`
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
### License
|
|
224
|
-
|
|
225
|
-
[MIT License](https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/LICENSE). Copyright (c) 2021 Denys Kozak
|
|
226
|
-
|
|
1
|
+
# QR Code Styling
|
|
2
|
+
[](https://www.npmjs.org/package/qr-code-styling)
|
|
3
|
+
|
|
4
|
+
JavaScript library for generating QR codes with a logo and styling.
|
|
5
|
+
|
|
6
|
+
Try it here https://qr-code-styling.com
|
|
7
|
+
|
|
8
|
+
If you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.
|
|
9
|
+
### Examples
|
|
10
|
+
<p float="left">
|
|
11
|
+
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/facebook_example_new.png" width="240" />
|
|
12
|
+
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/qr_code_example.png" width="240" />
|
|
13
|
+
<img style="display:inline-block" src="https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/telegram_example_new.png" width="240" />
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install qr-code-styling
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
```HTML
|
|
25
|
+
<!DOCTYPE html>
|
|
26
|
+
<html lang="en">
|
|
27
|
+
<head>
|
|
28
|
+
<meta charset="UTF-8">
|
|
29
|
+
<title>QR Code Styling</title>
|
|
30
|
+
<script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js"></script>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div id="canvas"></div>
|
|
34
|
+
<script type="text/javascript">
|
|
35
|
+
|
|
36
|
+
const qrCode = new QRCodeStyling.QRCodeStyling({
|
|
37
|
+
data: "https://www.facebook.com/",
|
|
38
|
+
image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
|
|
39
|
+
dotsOptions: {
|
|
40
|
+
color: "#4267b2",
|
|
41
|
+
type: "rounded"
|
|
42
|
+
},
|
|
43
|
+
backgroundOptions: {
|
|
44
|
+
color: "#e9ebee",
|
|
45
|
+
},
|
|
46
|
+
imageOptions: {
|
|
47
|
+
crossOrigin: "anonymous",
|
|
48
|
+
margin: 1
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
qrCode.append(document.getElementById("canvas"));
|
|
53
|
+
QRCodeStyling.browserUtils.download(qrCode);
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
57
|
+
```
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
[**React example (Codesandbox)**](https://codesandbox.io/s/qr-code-styling-react-example-l8rwl?file=/src/App.js)
|
|
61
|
+
|
|
62
|
+
[**Angular example (Codesandbox)**](https://codesandbox.io/s/agitated-panini-tpgb2?file=/src/app/app.component.ts)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
[**React example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/react)
|
|
67
|
+
|
|
68
|
+
[**Angular example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/angular)
|
|
69
|
+
|
|
70
|
+
[**Vue example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/vue)
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### API Documentation
|
|
75
|
+
|
|
76
|
+
#### QRCodeStyling instance
|
|
77
|
+
`new QRCodeStyling(options) => QRCodeStyling`
|
|
78
|
+
|
|
79
|
+
Param |Type |Description
|
|
80
|
+
-------|------|------------
|
|
81
|
+
options|object|Init object
|
|
82
|
+
|
|
83
|
+
`options` structure
|
|
84
|
+
|
|
85
|
+
Property |Type |Default Value|Description
|
|
86
|
+
-----------------------|-------------------------|-------------|-----------------------------------------------------
|
|
87
|
+
data |string | |The date will be encoded to the QR code
|
|
88
|
+
image |string | |The image will be copied to the center of the QR code
|
|
89
|
+
qrOptions |object | |Options will be passed to `qrcode-generator` lib
|
|
90
|
+
imageOptions |object | |Specific image options, details see below
|
|
91
|
+
dotsOptions |object | |Dots styling options
|
|
92
|
+
cornersSquareOptions |object | |Square in the corners styling options
|
|
93
|
+
cornersDotOptionsHelper|object | |Dots in the corners styling options
|
|
94
|
+
backgroundOptions |object | |QR background styling options
|
|
95
|
+
|
|
96
|
+
`options.qrOptions` structure
|
|
97
|
+
|
|
98
|
+
Property |Type |Default Value
|
|
99
|
+
--------------------|--------------------------------------------------|-------------
|
|
100
|
+
typeNumber |number (`0 - 40`) |`0`
|
|
101
|
+
mode |string (`'Numeric' 'Alphanumeric' 'Byte' 'Kanji'`)|
|
|
102
|
+
errorCorrectionLevel|string (`'L' 'M' 'Q' 'H'`) |`'Q'`
|
|
103
|
+
|
|
104
|
+
`options.imageOptions` structure
|
|
105
|
+
|
|
106
|
+
Property |Type |Default Value|Description
|
|
107
|
+
------------------|---------------------------------------|-------------|------------------------------------------------------------------------------
|
|
108
|
+
hideBackgroundDots|boolean |`true` |Hide all dots covered by the image
|
|
109
|
+
imageSize |number |`0.4` |Coefficient of the image size. Not recommended to use ove 0.5. Lower is better
|
|
110
|
+
margin |number |`0` |Margin of the image in blocks
|
|
111
|
+
crossOrigin |string(`'anonymous' 'use-credentials'`)| |Set "anonymous" if you want to download QR code from other origins.
|
|
112
|
+
|
|
113
|
+
`options.dotsOptions` structure
|
|
114
|
+
|
|
115
|
+
Property|Type |Default Value|Description
|
|
116
|
+
--------|------------------------------------------------------------------------------|-------------|-------------------
|
|
117
|
+
color |string |`'#000'` |Color of QR dots
|
|
118
|
+
gradient|object | |Gradient of QR dots
|
|
119
|
+
type |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded'`)|`'square'` |Style of QR dots
|
|
120
|
+
|
|
121
|
+
`options.backgroundOptions` structure
|
|
122
|
+
|
|
123
|
+
Property|Type |Default Value
|
|
124
|
+
--------|------|-------------
|
|
125
|
+
color |string|`'#fff'`
|
|
126
|
+
gradient|object|
|
|
127
|
+
|
|
128
|
+
`options.cornersSquareOptions` structure
|
|
129
|
+
|
|
130
|
+
Property|Type |Default Value|Description
|
|
131
|
+
--------|-----------------------------------------|-------------|-----------------
|
|
132
|
+
color |string | |Color of Corners Square
|
|
133
|
+
gradient|object | |Gradient of Corners Square
|
|
134
|
+
type |string (`'dot' 'square' 'extra-rounded'`)| |Style of Corners Square
|
|
135
|
+
|
|
136
|
+
`options.cornersDotOptions` structure
|
|
137
|
+
|
|
138
|
+
Property|Type |Default Value|Description
|
|
139
|
+
--------|-------------------------|-------------|-----------------
|
|
140
|
+
color |string | |Color of Corners Dot
|
|
141
|
+
gradient|object | |Gradient of Corners Dot
|
|
142
|
+
type |string (`'dot' 'square'`)| |Style of Corners Dot
|
|
143
|
+
|
|
144
|
+
Gradient structure
|
|
145
|
+
|
|
146
|
+
`options.dotsOptions.gradient`
|
|
147
|
+
|
|
148
|
+
`options.backgroundOptions.gradient`
|
|
149
|
+
|
|
150
|
+
`options.cornersSquareOptions.gradient`
|
|
151
|
+
|
|
152
|
+
`options.cornersDotOptions.gradient`
|
|
153
|
+
|
|
154
|
+
Property |Type |Default Value|Description
|
|
155
|
+
----------|----------------------------|-------------|---------------------------------------------------------
|
|
156
|
+
type |string (`'linear' 'radial'`)|"linear" |Type of gradient spread
|
|
157
|
+
rotation |number |0 |Rotation of gradient in radians (Math.PI === 180 degrees)
|
|
158
|
+
colorStops|array of objects | |Gradient colors. Example `[{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }]`
|
|
159
|
+
|
|
160
|
+
Gradient colorStops structure
|
|
161
|
+
|
|
162
|
+
`options.dotsOptions.gradient.colorStops[]`
|
|
163
|
+
|
|
164
|
+
`options.backgroundOptions.gradient.colorStops[]`
|
|
165
|
+
|
|
166
|
+
`options.cornersSquareOptions.gradient.colorStops[]`
|
|
167
|
+
|
|
168
|
+
`options.cornersDotOptions.gradient.colorStops[]`
|
|
169
|
+
|
|
170
|
+
Property|Type |Default Value|Description
|
|
171
|
+
--------|----------------|-------------|-----------------------------------
|
|
172
|
+
offset |number (`0 - 1`)| |Position of color in gradient range
|
|
173
|
+
color |string | |Color of stop in gradient range
|
|
174
|
+
|
|
175
|
+
#### QRCodeStyling methods
|
|
176
|
+
`QRCodeStyling.append(container) => void`
|
|
177
|
+
|
|
178
|
+
Param |Type |Description
|
|
179
|
+
---------|-----------|-----------
|
|
180
|
+
container|DOM element|This container will be used for appending of the QR code
|
|
181
|
+
|
|
182
|
+
`QRCodeStyling.serialize() => Promise<string>`
|
|
183
|
+
|
|
184
|
+
`QRCodeStyling.update(options) => void`
|
|
185
|
+
|
|
186
|
+
Param |Type |Description
|
|
187
|
+
-------|------|--------------------------------------
|
|
188
|
+
options|object|The same options as for initialization
|
|
189
|
+
|
|
190
|
+
`QRCodeStyling.applyExtension(extension) => void`
|
|
191
|
+
|
|
192
|
+
Param |Type |Description
|
|
193
|
+
---------|----------------------|------------------------------------------------------------------------------------------
|
|
194
|
+
extension|(svg, options) => void|Extension is a function that takes svg and previously applied options and modifies an svg
|
|
195
|
+
|
|
196
|
+
`applyExtension` example
|
|
197
|
+
|
|
198
|
+
```JS
|
|
199
|
+
const extension = (svg, options) => {
|
|
200
|
+
const { width, height } = options;
|
|
201
|
+
const size = Math.min(width, height);
|
|
202
|
+
const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
203
|
+
const borderAttributes = {
|
|
204
|
+
"fill": "none",
|
|
205
|
+
"x": (width - size + 40) / 2,
|
|
206
|
+
"y": (height - size + 40) / 2,
|
|
207
|
+
"width": size - 40,
|
|
208
|
+
"height": size - 40,
|
|
209
|
+
"stroke": 'black',
|
|
210
|
+
"stroke-width": 40,
|
|
211
|
+
"rx": 100,
|
|
212
|
+
};
|
|
213
|
+
Object.keys(borderAttributes).forEach(attribute => {
|
|
214
|
+
border.setAttribute(attribute, borderAttributes[attribute]);
|
|
215
|
+
});
|
|
216
|
+
svg.appendChild(border);
|
|
217
|
+
};
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`QRCodeStyling.deleteExtension() => void`
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
### License
|
|
224
|
+
|
|
225
|
+
[MIT License](https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/LICENSE). Copyright (c) 2021 Denys Kozak
|
|
226
|
+
|
package/package.json
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@liquid-js/qr-code-styling",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "Add a style and an image to your QR code",
|
|
5
|
-
"main": "lib/qr-code-styling-node.js",
|
|
6
|
-
"browser": "lib/qr-code-styling
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"lib"
|
|
10
|
-
],
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"file-type": "<17.0.0",
|
|
13
|
-
"jsdom": "^22.1.0",
|
|
14
|
-
"node-fetch": "<3.0.0",
|
|
15
|
-
"qrcode-generator": "^1.4.4",
|
|
16
|
-
"sharp": "^0.32.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@rollup/plugin-commonjs": "^25.0.1",
|
|
20
|
-
"@rollup/plugin-typescript": "^11.1.1",
|
|
21
|
-
"@types/jsdom": "^21.1.1",
|
|
22
|
-
"@types/node": "<19.0.0",
|
|
23
|
-
"@types/node-fetch": "^2.6.4",
|
|
24
|
-
"@types/sharp": "^0.31.1",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
26
|
-
"@typescript-eslint/parser": "^5.59.9",
|
|
27
|
-
"canvas": "^2.11.2",
|
|
28
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
29
|
-
"eslint": "^8.42.0",
|
|
30
|
-
"eslint-config-prettier": "^8.8.0",
|
|
31
|
-
"eslint-plugin-jest": "^27.2.1",
|
|
32
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
33
|
-
"eslint-webpack-plugin": "^4.0.1",
|
|
34
|
-
"html-webpack-plugin": "^5.5.3",
|
|
35
|
-
"jest": "^29.5.0",
|
|
36
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
37
|
-
"prettier": "^2.8.8",
|
|
38
|
-
"rollup": "^3.25.0",
|
|
39
|
-
"ts-jest": "^29.1.0",
|
|
40
|
-
"ts-loader": "^9.4.3",
|
|
41
|
-
"typescript": "^5.1.3",
|
|
42
|
-
"webpack": "^5.86.0",
|
|
43
|
-
"webpack-cli": "^5.1.4",
|
|
44
|
-
"webpack-dev-server": "^4.15.1",
|
|
45
|
-
"webpack-merge": "^5.9.0"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"build": "webpack --mode=production --config webpack.config.build.js && rollup -c rollup.config.mjs",
|
|
49
|
-
"build:dev": "webpack --mode=development --config webpack.config.build.js",
|
|
50
|
-
"test": "jest",
|
|
51
|
-
"start": "webpack serve --open --config webpack.config.dev-server.js",
|
|
52
|
-
"lint": "eslint . --fix",
|
|
53
|
-
"prepublishOnly": "npm run build"
|
|
54
|
-
},
|
|
55
|
-
"repository": {
|
|
56
|
-
"type": "git",
|
|
57
|
-
"url": "git+https://github.com/kozakdenys/qr-code-styling.git"
|
|
58
|
-
},
|
|
59
|
-
"keywords": [
|
|
60
|
-
"qr",
|
|
61
|
-
"qrcode",
|
|
62
|
-
"qr-code",
|
|
63
|
-
"js",
|
|
64
|
-
"qrjs",
|
|
65
|
-
"qrstyling",
|
|
66
|
-
"styling",
|
|
67
|
-
"qrbranding",
|
|
68
|
-
"branding",
|
|
69
|
-
"qrimage",
|
|
70
|
-
"image",
|
|
71
|
-
"qrlogo",
|
|
72
|
-
"logo",
|
|
73
|
-
"design"
|
|
74
|
-
],
|
|
75
|
-
"author": "Denys Kozak <kozak.denys.dev@gmail.com>",
|
|
76
|
-
"license": "MIT",
|
|
77
|
-
"bugs": {
|
|
78
|
-
"url": "https://github.com/kozakdenys/qr-code-styling/issues"
|
|
79
|
-
},
|
|
80
|
-
"homepage": "https://qr-code-styling.com"
|
|
81
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@liquid-js/qr-code-styling",
|
|
3
|
+
"version": "1.6.2",
|
|
4
|
+
"description": "Add a style and an image to your QR code",
|
|
5
|
+
"main": "lib/qr-code-styling-node.js",
|
|
6
|
+
"browser": "lib/qr-code-styling.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"lib"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"file-type": "<17.0.0",
|
|
13
|
+
"jsdom": "^22.1.0",
|
|
14
|
+
"node-fetch": "<3.0.0",
|
|
15
|
+
"qrcode-generator": "^1.4.4",
|
|
16
|
+
"sharp": "^0.32.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@rollup/plugin-commonjs": "^25.0.1",
|
|
20
|
+
"@rollup/plugin-typescript": "^11.1.1",
|
|
21
|
+
"@types/jsdom": "^21.1.1",
|
|
22
|
+
"@types/node": "<19.0.0",
|
|
23
|
+
"@types/node-fetch": "^2.6.4",
|
|
24
|
+
"@types/sharp": "^0.31.1",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
26
|
+
"@typescript-eslint/parser": "^5.59.9",
|
|
27
|
+
"canvas": "^2.11.2",
|
|
28
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
29
|
+
"eslint": "^8.42.0",
|
|
30
|
+
"eslint-config-prettier": "^8.8.0",
|
|
31
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
32
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
33
|
+
"eslint-webpack-plugin": "^4.0.1",
|
|
34
|
+
"html-webpack-plugin": "^5.5.3",
|
|
35
|
+
"jest": "^29.5.0",
|
|
36
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
37
|
+
"prettier": "^2.8.8",
|
|
38
|
+
"rollup": "^3.25.0",
|
|
39
|
+
"ts-jest": "^29.1.0",
|
|
40
|
+
"ts-loader": "^9.4.3",
|
|
41
|
+
"typescript": "^5.1.3",
|
|
42
|
+
"webpack": "^5.86.0",
|
|
43
|
+
"webpack-cli": "^5.1.4",
|
|
44
|
+
"webpack-dev-server": "^4.15.1",
|
|
45
|
+
"webpack-merge": "^5.9.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "webpack --mode=production --config webpack.config.build.js && rollup -c rollup.config.mjs",
|
|
49
|
+
"build:dev": "webpack --mode=development --config webpack.config.build.js",
|
|
50
|
+
"test": "jest",
|
|
51
|
+
"start": "webpack serve --open --config webpack.config.dev-server.js",
|
|
52
|
+
"lint": "eslint . --fix",
|
|
53
|
+
"prepublishOnly": "npm run build"
|
|
54
|
+
},
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/kozakdenys/qr-code-styling.git"
|
|
58
|
+
},
|
|
59
|
+
"keywords": [
|
|
60
|
+
"qr",
|
|
61
|
+
"qrcode",
|
|
62
|
+
"qr-code",
|
|
63
|
+
"js",
|
|
64
|
+
"qrjs",
|
|
65
|
+
"qrstyling",
|
|
66
|
+
"styling",
|
|
67
|
+
"qrbranding",
|
|
68
|
+
"branding",
|
|
69
|
+
"qrimage",
|
|
70
|
+
"image",
|
|
71
|
+
"qrlogo",
|
|
72
|
+
"logo",
|
|
73
|
+
"design"
|
|
74
|
+
],
|
|
75
|
+
"author": "Denys Kozak <kozak.denys.dev@gmail.com>",
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/kozakdenys/qr-code-styling/issues"
|
|
79
|
+
},
|
|
80
|
+
"homepage": "https://qr-code-styling.com"
|
|
81
|
+
}
|