2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import QRCodeElement from 'qrcode.react';
|
2018-04-06 03:56:05 +02:00
|
|
|
import classnames from 'classnames';
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
value: string,
|
2018-04-06 03:56:05 +02:00
|
|
|
paddingRight?: boolean,
|
2018-06-12 15:22:53 +02:00
|
|
|
paddingTop?: boolean,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
2018-04-06 03:56:05 +02:00
|
|
|
class QRCode extends React.Component<Props> {
|
|
|
|
static defaultProps = {
|
|
|
|
paddingRight: false,
|
2018-06-12 15:22:53 +02:00
|
|
|
paddingTop: false,
|
2018-04-06 03:56:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2018-06-13 17:43:04 +02:00
|
|
|
const { value, paddingRight, paddingTop } = this.props;
|
2018-04-06 03:56:05 +02:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={classnames('qr-code', {
|
|
|
|
'qr-code--right-padding': paddingRight,
|
2018-06-12 15:22:53 +02:00
|
|
|
'qr-code--top-padding': paddingTop,
|
2018-04-06 03:56:05 +02:00
|
|
|
})}
|
|
|
|
>
|
2018-06-13 17:43:04 +02:00
|
|
|
<QRCodeElement value={value} />
|
2018-04-06 03:56:05 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
export default QRCode;
|