@qr-platform/qr-code.js 0.20.8 → 0.20.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @qr-platform/qr-code-js
2
2
 
3
+ ## 0.20.10
4
+
5
+ ### Patch Changes
6
+
7
+ - b03c01d: Update to style template border related issue
8
+
9
+ ## 0.20.9
10
+
11
+ ### Patch Changes
12
+
13
+ - b9f5505: Added mask cutout for transparent background with solid color border
14
+
3
15
  ## 0.20.8
4
16
 
5
17
  ### Patch Changes
@@ -361,7 +361,7 @@ qrGradientMultiple.append(document.getElementById('gradient-multiple-container')
361
361
 
362
362
  Embeds logos or images within the QR code.
363
363
 
364
- **Example 1: Centered Logo with Fill**
364
+ **Example 1: Centered Logo with Background Color and Padding**
365
365
 
366
366
  ```typescript
367
367
  const qrImageCenter = new QRCodeJs({
@@ -371,9 +371,11 @@ const qrImageCenter = new QRCodeJs({
371
371
  imageOptions: {
372
372
  mode: 'center',
373
373
  imageSize: 0.35,
374
- margin: 3,
375
- crossOrigin: 'anonymous',
376
- fill: { color: 'rgba(255,255,255,0.8)' } // Semi-transparent white fill behind logo
374
+ margin: 0.5, // Keep margin minimal (in blocks) or QR code may disappear
375
+ backgroundColor: 'rgba(255,255,255,0.9)', // Semi-transparent white background behind logo
376
+ padding: 10, // 10px padding around the image
377
+ radius: '10%', // Rounded corners with 10% radius
378
+ crossOrigin: 'anonymous'
377
379
  },
378
380
  dotsOptions: { color: '#C13584' } // Instagram-like color
379
381
  });
@@ -403,10 +405,104 @@ const qrImageBackground = new QRCodeJs({
403
405
  qrImageBackground.append(document.getElementById('image-background-container'));
404
406
  ```
405
407
 
406
- **Example 3: Using the Override Option with Images**
408
+ **Example 3: Logo with Custom Styling**
407
409
 
408
410
  ```typescript
411
+ const qrImageStyled = new QRCodeJs({
412
+ data: 'https://example.com/styled-logo',
413
+ image: 'data:image/svg+xml;base64,P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TksMjIxLjg5MywxMC4wNTksMzIzLjc4OSwxMDUuMTczLDQ4MS4xOTNjNy44NzctNzAuMzU3LDQxLjY1My0yMjUuNDg1LDE4Ni44ODgtMjYwLjg4NA0KCUMyOTIuMDUzLDIyMC4zMSwxNTcuMjc5LDI3MC43MywxNDUuMDA3LDQ5OC43MDR6Ii8+DQo8Y2lyY2xlIHN0eWxlPSJmaWxsOiMzQTdGMEQ7IiBjeD0iOTAuNDU5IiBjeT0iMTcxLjk4NSIgcj0iMTMuNzg1Ii8+DQo8Zz4NCgk8Y2lyY2xlIHN0eWxlPSJmaWxsOiM0OUEwMTA7IiBjeD0iMTMzLjc4MiIgY3k9IjE1OC4yIiByPSI5Ljg0NiIvPg0KCTxjaXJjbGUgc3R5bGU9ImZpbGw6IzQ5QTAxMDsiIGN4PSIxMjQuOTIxIiBjeT0iNjQuNjYyIiByPSIyNC42MTUiLz4NCgk8Y2lyY2xlIHN0eWxlPSJmaWxsOiM0OUEwMTA7IiBjeD0iMjAwLjczNiIgY3k9IjEyMC43ODUiIHI9IjcuODc3Ii8+DQoJPGNpcmNsZSBzdHlsZT0iZmlsbDojNDlBMDEwOyIgY3g9IjI2Ni43MTMiIGN5PSI3Ni40NzciIHI9IjIyLjY0NiIvPg0KPC9nPg0KPC9zdmc+', // Leaf SVG logo
414
+ imageOptions: {
415
+ mode: 'center',
416
+ imageSize: 0.5,
417
+ backgroundColor: '#8e44ad', // Purple background
418
+ padding: 8, // 8px padding
419
+ radius: '5%', // 5% rounded corners
420
+ margin: 0.5 // Minimal margin to prevent QR code from disappearing
421
+ },
422
+ dotsOptions: {
423
+ type: 'rounded',
424
+ color: '#2c3e50' // Dark blue-gray dots
425
+ }
426
+ });
427
+ qrImageStyled.append(document.getElementById('image-styled-container'));
428
+ ```
429
+
430
+ **Example 4: Logo with Gradient Background and Circle Shape**
409
431
 
432
+ ```typescript
433
+ const qrImageGradientBg = new QRCodeJs({
434
+ data: 'https://example.com/gradient-logo',
435
+ shape: 'circle',
436
+ image: 'https://example.com/company-logo.png',
437
+ imageOptions: {
438
+ mode: 'center',
439
+ imageSize: 0.4,
440
+ backgroundColor: '#ffffff', // White background for logo
441
+ padding: 15, // 15px padding for breathing room
442
+ radius: '50%', // Circular logo background
443
+ margin: 0.3 // Very minimal margin
444
+ },
445
+ dotsOptions: {
446
+ type: 'extraRounded',
447
+ gradient: {
448
+ type: 'radial',
449
+ colorStops: [
450
+ { offset: 0, color: '#667eea' }, // Purple center
451
+ { offset: 1, color: '#764ba2' } // Pink edge
452
+ ]
453
+ }
454
+ },
455
+ backgroundOptions: {
456
+ color: '#fafafa'
457
+ }
458
+ });
459
+ qrImageGradientBg.append(document.getElementById('image-gradient-bg-container'));
460
+ ```
461
+
462
+ **Example 5: Demonstrating Margin Impact (Warning Example)**
463
+
464
+ ```typescript
465
+ // WARNING: High margin values can cause QR code to disappear
466
+ // This example shows both correct and incorrect usage
467
+
468
+ // CORRECT: Minimal margin value
469
+ const qrCorrectMargin = new QRCodeJs({
470
+ data: 'https://example.com/correct-margin',
471
+ image: 'https://example.com/logo.png',
472
+ imageOptions: {
473
+ mode: 'center',
474
+ imageSize: 0.3,
475
+ margin: 0.5, // Small margin - QR code remains visible
476
+ backgroundColor: '#e3f2fd',
477
+ padding: 5,
478
+ radius: '8px'
479
+ },
480
+ dotsOptions: { color: '#1976d2' }
481
+ });
482
+ qrCorrectMargin.append(document.getElementById('correct-margin-container'));
483
+
484
+ // INCORRECT: Large margin value (DO NOT USE IN PRODUCTION)
485
+ // This is shown for educational purposes only
486
+ const qrIncorrectMargin = new QRCodeJs({
487
+ data: 'https://example.com/incorrect-margin',
488
+ image: 'https://example.com/logo.png',
489
+ imageOptions: {
490
+ mode: 'center',
491
+ imageSize: 0.4,
492
+ margin: 5, // TOO LARGE! May cause QR code to disappear or become unscannable
493
+ backgroundColor: '#ffebee',
494
+ padding: 5,
495
+ radius: '8px'
496
+ },
497
+ dotsOptions: { color: '#d32f2f' }
498
+ });
499
+ // QR code may not render properly or disappear entirely
500
+ qrIncorrectMargin.append(document.getElementById('incorrect-margin-container'));
501
+ ```
502
+
503
+ **Example 6: Using the Override Option with Images**
504
+
505
+ ```typescript
410
506
  // Setting a global image with override that will take precedence
411
507
  // even over images specified in instance options
412
508
  QRCodeJs.setImage('https://example.com/global-priority-logo.png', { override: true });
@@ -415,6 +511,12 @@ QRCodeJs.setImage('https://example.com/global-priority-logo.png', { override: tr
415
511
  const qrImageOverride = new QRCodeJs({
416
512
  data: 'https://example.com/image-override-example',
417
513
  image: 'https://example.com/this-will-be-ignored.png', // Will be ignored due to override
514
+ imageOptions: {
515
+ backgroundColor: '#ffffff',
516
+ padding: 10,
517
+ radius: '5px',
518
+ margin: 0.4
519
+ },
418
520
  dotsOptions: { color: '#333333' }
419
521
  });
420
522
  qrImageOverride.append(document.getElementById('image-override-container'));
@@ -424,6 +526,12 @@ const qrBuilderImageOverride = QRCodeJs.useImage('https://example.com/builder-pr
424
526
  .options({
425
527
  data: 'https://example.com/builder-image-override-example',
426
528
  image: 'https://example.com/another-ignored-image.png', // Will be ignored due to override
529
+ imageOptions: {
530
+ backgroundColor: 'rgba(255, 255, 255, 0.95)',
531
+ padding: 12,
532
+ radius: '10%',
533
+ margin: 0.4
534
+ },
427
535
  dotsOptions: { type: 'rounded', color: '#555555' }
428
536
  });
429
537
  qrBuilderImageOverride.append(document.getElementById('builder-image-override-container'));
@@ -56,11 +56,11 @@ qrCode.append(document.getElementById('qr-container'));
56
56
  | `imageOptions` | `object` | `{...}` | Options for the embedded image. |
57
57
  | `imageOptions.mode` | `ImageMode` enum | `'center'` | How the image is embedded. See `ImageMode` enum. |
58
58
  | `imageOptions.imageSize` | `number` | `0.4` | Relative size of the image (0-1). |
59
- | `imageOptions.margin` | `number` | `0` | Margin around the image in dot units. |
59
+ | `imageOptions.margin` | `number` | `0` | Margin around the image in blocks. **Warning: Keep minimal or QR code may disappear.** |
60
+ | `imageOptions.backgroundColor` | `string` | `undefined` | Background color of QR code image (logo). |
61
+ | `imageOptions.padding` | `number` | `0` | Padding around the image in pixels. |
62
+ | `imageOptions.radius` | `string \| number` | `undefined` | Border radius of the image (e.g., "10px" or 10). |
60
63
  | `imageOptions.crossOrigin` | `string` | `undefined` | CORS setting for the image. |
61
- | `imageOptions.fill` | `object` | `{...}` | Fill `color` or `gradient`. |
62
- | `imageOptions.fill.color` | `string` | `'rgba(255,255,255,1)'` | Fill color.
63
- | `imageOptions.fill.gradient` | `Gradient` object | `undefined` | Apply a gradient fill to the QR code. See [Gradient options](#gradientoptions) for configuration details.
64
64
  | `borderOptions` | `BorderOptions` object | `undefined` | Options for adding decorative borders. Can be configured globally via `QRCodeJs.setBorder()`/`setBorderId()` or per-instance via the builder pattern (`useBorder()`/`useBorderId()`). See below for sub-options. |
65
65
 
66
66
  ---
@@ -567,7 +567,7 @@ Options for the embedded image.
567
567
 
568
568
  ## Gradients
569
569
 
570
- Gradients can be applied to multiple elements: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, `backgroundOptions`, and `imageOptions.fill`.
570
+ Gradients can be applied to multiple elements: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, and `backgroundOptions`.
571
571
 
572
572
  ### Gradient Structure
573
573
 
@@ -266,7 +266,7 @@ Options for applying gradient fills to various QR code elements (dots, corner sq
266
266
  | `colorStops`| `Array<{ offset: number, color: string }>` | - | Array of color stops defining the gradient (offset: 0-1, color: CSS string). At least two stops recommended. |
267
267
 
268
268
  **Where to Apply Gradients:**
269
- Add a `gradient` property to: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, `backgroundOptions`, and `imageOptions.fill`.
269
+ Add a `gradient` property to: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, and `backgroundOptions`.
270
270
 
271
271
  *Note: If both `color` and `gradient` are set, `gradient` takes precedence.*
272
272
 
@@ -309,11 +309,11 @@ const qrCodeWithGradient = new QRCodeJs({
309
309
  | `image` | `string \| Buffer \| Blob` | `undefined` | URL, Buffer, or Blob of an image to embed in the QR code. |
310
310
  | `imageOptions.mode` | `ImageMode` enum | `'center'` | How the image is embedded. |
311
311
  | `imageOptions.imageSize` | `number` | `0.4` | Relative size of the image (0-1). |
312
- | `imageOptions.margin` | `number` | `0` | Margin around the image in dot units. |
312
+ | `imageOptions.margin` | `number` | `0` | Margin around the image in blocks. **Warning: Keep minimal or QR code may disappear.** |
313
+ | `imageOptions.backgroundColor` | `string` | `undefined` | Background color of QR code image (logo). |
314
+ | `imageOptions.padding` | `number` | `0` | Padding around the image in pixels. |
315
+ | `imageOptions.radius` | `string \| number` | `undefined` | Border radius of the image (e.g., "10px" or 10). |
313
316
  | `imageOptions.crossOrigin`| `string` | `undefined` | CORS setting for the image (e.g., `'anonymous'`, `'use-credentials'`). |
314
- | `imageOptions.fill` | `object` | `{...}` | Fill options for transparent areas (used in `'center'` mode). |
315
- | `imageOptions.fill.color` | `string` | `'rgba(255,255,255,1)'` | Fill color for transparent areas. |
316
- | `imageOptions.fill.gradient`| `Gradient` object | `undefined` | Apply a gradient fill to transparent areas. See [Gradients](#gradients) for configuration details. |
317
317
 
318
318
  **Note on Image Source:** The `image` can be specified directly in the options, set globally for subsequent instances using `QRCodeJs.setImage('your_image_url')`, or set for a specific builder chain using `QRCodeJs.useImage('your_image_url').options(...)`. The builder's `useImage` typically overrides the global `setImage`, which in turn overrides an image set by a template. Direct options in the constructor or `.options()` call provide the final override.
319
319