From b6349468230377eabbe31877f751167413ad01a7 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 15 Aug 2016 19:12:46 +0300 Subject: Switch to img based code --- base.scss | 6 ++++++ index.js | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/base.scss b/base.scss index 83a8bee..0eb3006 100644 --- a/base.scss +++ b/base.scss @@ -17,7 +17,13 @@ body { h1 { margin: 20px; } + p.save { + font-size: 0.7em; + } canvas#qr { + display: none; + } + img#qrimg { display: block; margin: 10px auto; padding: 20px; diff --git a/index.js b/index.js index 82d7973..306a819 100644 --- a/index.js +++ b/index.js @@ -20,16 +20,14 @@ class Qrgen extends React.Component { value: this.state.text, size: this.state.size }) + this.refs.qrimg.src = this.qr.toDataURL() } + componentDidUpdate (prevProps, prevState) { this.qr.value = this.state.text this.qr.size = this.state.size - } - - saveImage () { - this.refs.dl.download = 'qrgen-test.png' - this.refs.dl.href = this.qr.toDataURL() + this.refs.qrimg.src = this.qr.toDataURL() } render () { @@ -41,8 +39,9 @@ class Qrgen extends React.Component { { this.setState(Object.assign({}, this.state, { size: e.target.value })) }}> - { this.saveImage() }}>Save QR Code +
To save the QR code, right-click the image and 'Save Image As', or touch and hold the image on your mobile browser.
+