Space-saving QR Code Generator – qrize.js

Category: Javascript | October 15, 2018
Author: qrize
Views Total: 1,492
Official Page: Go to website
Last Update: October 15, 2018
License: MIT

Preview:

Space-saving QR Code Generator – qrize.js

Description:

qrize.js is a JavaScript library used to generate space-saving, image/SVG/table based QR codes with URL shortener service integration.

How to use it:

Install and import the qrize.js package.

# Yarn
$ yarn add qrize

# NPM
$ npm install qrize --save
import Qrize from "qrize";

Or include the ‘qrize.umd.js’ directly on the web page.

<script src="qrize.umd.js"></script>

Create a container to place the generated QR code.

<div id="target"></div>

Initialize the QR code generator.

var qr = new Qrize({
    element: document.getElementById('target')
});

Generate a QR code inside the container.

qrize.createImg({ 
  url: "https://www.cssscript.com/" 
});

// or
qrize.createSvg({ 
  url: "https://www.cssscript.com/" 
});

// or
qrize.createTable({ 
  url: "https://www.cssscript.com/" 
});

To config the QR generator just by passing the following parameters to the constructor.

const qrize = new Qrize({
      element: document.getElementById("qr-target"),
      cellSize: 2,
      margin: 0
});

Callback functions.

qrize.createImg({ 
  url: "https://www.cssscript.com/",
  onSuccess: function onQrizeSuccess() {
    console.log('Success');
  },
  onFailure: function onQrizeFailure(status, text) {
    console.log('Failure: ', status, text);
  }
});

API methods.

Qrize.getHash({
  url: 'https://www.cssscript.com/',
  onSuccess({ hash }) {
    console.log(hash);
  }
})

Qrize.getUrl({
  hash: 'xxx',
  onSuccess({ url }) {
    console.log(url);
  }
})

Changelog:

v0.4.0 (10/15/2018)

  • Add flow annotations

You Might Be Interested In:


Leave a Reply