If you want to help support the project, you can donate a beer's worth of rai using this
form
diff --git a/src/components/ReblocksQRCode/ReblocksQRCode.story.tsx b/src/components/ReblocksQRCode/ReblocksQRCode.story.tsx
new file mode 100644
index 0000000..a75df63
--- /dev/null
+++ b/src/components/ReblocksQRCode/ReblocksQRCode.story.tsx
@@ -0,0 +1,36 @@
+import { storiesOf } from '@storybook/react';
+import * as React from 'react';
+
+import { ReblocksQRCode } from './ReblocksQRCode';
+
+import { ACCOUNT_ID } from '../../lib/';
+
+storiesOf('ReblocksQRCode', module)
+ .add('Default', () => {
+ return ;
+ })
+ .add('Default with Address', () => {
+ return ;
+ })
+ .add('With Amount', () => {
+ return ;
+ })
+ .add('With Amount and Label', () => {
+ return (
+
+ );
+ })
+ .add('Amount, Label and Message', () => {
+ return (
+
+ );
+ })
+ .add('RaiBlocks Purple', () => {
+ return ;
+ });
diff --git a/src/components/ReblocksQRCode/ReblocksQRCode.tsx b/src/components/ReblocksQRCode/ReblocksQRCode.tsx
new file mode 100644
index 0000000..8771c7d
--- /dev/null
+++ b/src/components/ReblocksQRCode/ReblocksQRCode.tsx
@@ -0,0 +1,58 @@
+import * as QRCode from 'qrcode.react';
+import * as queryString from 'query-string';
+import * as React from 'react';
+
+export interface OptionalProps {
+ amount?: number;
+ bgColor?: string;
+ fgColor?: string;
+ label?: string;
+ message?: string;
+ size?: number;
+ showUrl?: boolean;
+}
+
+export interface Props extends OptionalProps {
+ accountId: string;
+}
+
+const ReblocksQRCode: React.StatelessComponent = (props): JSX.Element => {
+ const { accountId, amount, label, message, showUrl, ...otherProps } = props;
+ let address = `xrb:${accountId}`;
+
+ const params: OptionalProps = {};
+ if (amount) {
+ params.amount = amount;
+ }
+ if (label) {
+ params.label = label;
+ }
+ if (message) {
+ params.message = message;
+ }
+
+ const qs = queryString.stringify(params);
+ address = qs ? `${address}?${qs}` : address;
+
+ const qrComponent = ;
+
+ if (showUrl) {
+ return (
+
+ {qrComponent}
+
{address}
+
+ );
+ }
+
+ return qrComponent;
+};
+
+ReblocksQRCode.defaultProps = {
+ bgColor: '#FFFFFF',
+ fgColor: '#000000',
+ showUrl: false,
+ size: 128
+};
+
+export { ReblocksQRCode };
diff --git a/src/reblocks.ts b/src/reblocks.ts
index 66bb66c..9422f09 100644
--- a/src/reblocks.ts
+++ b/src/reblocks.ts
@@ -1,4 +1,5 @@
export { PaymentResponse, ReblocksPayment } from './components/ReblocksPayment/ReblocksPayment';
export { ReblocksFiatConversion } from './components/ReblocksFiatConversion/ReblocksFiatConversion';
+export { ReblocksQRCode } from './components/ReblocksQRCode/ReblocksQRCode';
export * from './lib';
diff --git a/yarn.lock b/yarn.lock
index eea9e22..63fd711 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -334,6 +334,16 @@
version "15.5.2"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.2.tgz#3c6b8dceb2906cc87fe4358e809f9d20c8d59be1"
+"@types/qrcode.react@^0.6.2":
+ version "0.6.2"
+ resolved "https://registry.yarnpkg.com/@types/qrcode.react/-/qrcode.react-0.6.2.tgz#c3c09a1f01c8f1378b2dc9cde27a15cc1529cf19"
+ dependencies:
+ "@types/react" "*"
+
+"@types/query-string@^5.0.1":
+ version "5.0.1"
+ resolved "https://registry.yarnpkg.com/@types/query-string/-/query-string-5.0.1.tgz#6cb41c724cb1644d56c2d1dae7c7b204e706b39e"
+
"@types/react-select@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@types/react-select/-/react-select-1.1.0.tgz#b3ddf7a58f033f69d3c47c825587a54fec1629c6"
@@ -7303,6 +7313,17 @@ q@^1.1.2, q@^1.4.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
+qr.js@0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/qr.js/-/qr.js-0.0.0.tgz#cace86386f59a0db8050fa90d9b6b0e88a1e364f"
+
+qrcode.react@^0.7.2:
+ version "0.7.2"
+ resolved "https://registry.yarnpkg.com/qrcode.react/-/qrcode.react-0.7.2.tgz#72a5718fd56baafe15c2c153fe436628d83aa286"
+ dependencies:
+ prop-types "^15.5.8"
+ qr.js "0.0.0"
+
qs@6.5.1, qs@^6.5.1, qs@~6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"