Skip to content

Instantly share code, notes, and snippets.

@filiptronicek
Created August 14, 2018 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filiptronicek/0254748fe3a2fd91af3414f31299be97 to your computer and use it in GitHub Desktop.
Save filiptronicek/0254748fe3a2fd91af3414f31299be97 to your computer and use it in GitHub Desktop.
Create QR Code
div
h1 Create QR Code
input(type="text" placeholder="Type something")
canvas#qr
const input = document.querySelector("input")
const canvas = document.getElementById("qr")
const createQR = (v) => {
// https://github.com/neocotic/qrious
return new QRious({
element: canvas,
value: v,
size: 400,
backgroundAlpha: 0,
foreground: "white",
})
}
const qr = createQR(input.value)
input.addEventListener("input", () => {
const qr = createQR(input.value)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
html,
body
height 100%
body
display flex
align-items center
justify-content center
font-family "Open Sans", sans-serif
background-color black
color white
div
display flex
flex-direction column
align-items center
input
font-size 1rem
font-family "Open Sans", sans-serif
text-align center
margin-bottom 4rem
border none
border-bottom 2px solid white
padding .5rem
background-color transparent
color white
outline none
input::placeholder
color white
// Retina Resolution
canvas
width 200px
height 200px
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment