add togglable QR code to wallet address component #1582
3 changed files with 37 additions and 2 deletions
|
@ -6,19 +6,22 @@ import classnames from 'classnames';
|
||||||
type Props = {
|
type Props = {
|
||||||
value: string,
|
value: string,
|
||||||
paddingRight?: boolean,
|
paddingRight?: boolean,
|
||||||
|
paddingTop?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class QRCode extends React.Component<Props> {
|
class QRCode extends React.Component<Props> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
paddingRight: false,
|
paddingRight: false,
|
||||||
|
paddingTop: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { value, paddingRight } = this.props;
|
const { value, paddingRight, paddingTop } = this.props;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames('qr-code', {
|
className={classnames('qr-code', {
|
||||||
'qr-code--right-padding': paddingRight,
|
'qr-code--right-padding': paddingRight,
|
||||||
|
'qr-code--top-padding': paddingTop,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<QRCodeElement value={value} />
|
<QRCodeElement value={value} />
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import Address from 'component/address';
|
import Address from 'component/address';
|
||||||
|
import QRCode from 'component/common/qr-code';
|
||||||
import * as icons from 'constants/icons';
|
import * as icons from 'constants/icons';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -12,6 +13,20 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class WalletAddress extends React.PureComponent<Props> {
|
class WalletAddress extends React.PureComponent<Props> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
showQR: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleQR() {
|
||||||
|
this.setState({
|
||||||
|
showQR: !this.state.showQR,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const { checkAddressIsMine, receiveAddress, getNewAddress } = this.props;
|
const { checkAddressIsMine, receiveAddress, getNewAddress } = this.props;
|
||||||
if (!receiveAddress) {
|
if (!receiveAddress) {
|
||||||
|
@ -23,6 +38,7 @@ class WalletAddress extends React.PureComponent<Props> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { receiveAddress, getNewAddress, gettingNewAddress } = this.props;
|
const { receiveAddress, getNewAddress, gettingNewAddress } = this.props;
|
||||||
|
const { showQR } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="card card--section">
|
<section className="card card--section">
|
||||||
|
@ -43,7 +59,17 @@ class WalletAddress extends React.PureComponent<Props> {
|
||||||
onClick={getNewAddress}
|
onClick={getNewAddress}
|
||||||
disabled={gettingNewAddress}
|
disabled={gettingNewAddress}
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
button="link"
|
||||||
|
label={showQR ? __('Hide QR code') : __('Show QR code')}
|
||||||
|
onClick={this.toggleQR.bind(this)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="card__content">
|
||||||
|
{showQR && <QRCode value={receiveAddress} paddingTop />}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
<div className="help">
|
<div className="help">
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -356,7 +356,13 @@ p {
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr-code {
|
.qr-code {
|
||||||
|
border: 3px solid var(--color-white);
|
||||||
|
height: 134px;
|
||||||
|
width: 134px;
|
||||||
&.qr-code--right-padding {
|
&.qr-code--right-padding {
|
||||||
padding-right: $spacing-vertical * 2/3;
|
margin-right: $spacing-vertical * 2/3;
|
||||||
|
}
|
||||||
|
&.qr-code--top-padding {
|
||||||
|
margin-top: $spacing-vertical * 2/3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue