Display QrCode for accounts, addresses & contracts (#4329)

* Display QrCode for accounts, addresses & contracts

* Default size 4

* Fix layouts
This commit is contained in:
Jaco Greeff 2017-01-27 21:55:20 +01:00 committed by GitHub
parent 5246d51a1a
commit aef699ebf2
3 changed files with 117 additions and 38 deletions

View File

@ -14,17 +14,30 @@
/* You should have received a copy of the GNU General Public License /* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>. /* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/ */
.balances, .tags {
clear: both;
}
.editicon { .editicon {
margin-left: 0.5em; margin-left: 0.5em;
} }
.floatleft { .info {
margin: 0 156px 0 0;
}
.identityIcon {
float: left; float: left;
margin-bottom: 0.5em; margin-right: -100%;
}
.qrcode {
float: right;
margin-top: 1.5em;
}
.addressline,
.infoline,
.uuidline,
.title {
margin-left: 72px;
} }
.addressline, .addressline,
@ -50,3 +63,7 @@
display: inline-block; display: inline-block;
margin-left: .5em; margin-left: .5em;
} }
.tags {
clear: both;
}

View File

@ -17,9 +17,7 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { Balance, Container, ContainerTitle, IdentityIcon, IdentityName, Tags } from '~/ui'; import { Balance, Certifications, Container, CopyToClipboard, ContainerTitle, IdentityIcon, IdentityName, QrCode, Tags } from '~/ui';
import CopyToClipboard from '~/ui/CopyToClipboard';
import Certifications from '~/ui/Certifications';
import styles from './header.css'; import styles from './header.css';
@ -53,8 +51,15 @@ export default class Header extends Component {
return ( return (
<div className={ className }> <div className={ className }>
<Container> <Container>
<IdentityIcon address={ address } /> <QrCode
<div className={ styles.floatleft }> className={ styles.qrcode }
value={ address }
/>
<IdentityIcon
address={ address }
className={ styles.identityIcon }
/>
<div className={ styles.info }>
{ this.renderName() } { this.renderName() }
<div className={ [ hideName ? styles.bigaddress : '', styles.addressline ].join(' ') }> <div className={ [ hideName ? styles.bigaddress : '', styles.addressline ].join(' ') }>
<CopyToClipboard data={ address } /> <CopyToClipboard data={ address } />
@ -65,17 +70,17 @@ export default class Header extends Component {
{ meta.description } { meta.description }
</div> </div>
{ this.renderTxCount() } { this.renderTxCount() }
<div className={ styles.balances }>
<Balance
account={ account }
balance={ balance }
/>
<Certifications address={ address } />
</div>
</div> </div>
<div className={ styles.tags }> <div className={ styles.tags }>
<Tags tags={ meta.tags } /> <Tags tags={ meta.tags } />
</div> </div>
<div className={ styles.balances }>
<Balance
account={ account }
balance={ balance }
/>
<Certifications address={ address } />
</div>
{ children } { children }
</Container> </Container>
</div> </div>
@ -93,6 +98,7 @@ export default class Header extends Component {
return ( return (
<ContainerTitle <ContainerTitle
className={ styles.title }
title={ title={
<IdentityName <IdentityName
address={ address } address={ address }

View File

@ -68,37 +68,93 @@ describe('views/Account/Header', () => {
}); });
describe('sections', () => { describe('sections', () => {
it('renders the Balance', () => { describe('Balance', () => {
render({ balance: { balance: 'testing' } }); let balance;
const balance = component.find('Connect(Balance)');
expect(balance).to.have.length(1); beforeEach(() => {
expect(balance.props().account).to.deep.equal(ACCOUNT); render({ balance: { balance: 'testing' } });
expect(balance.props().balance).to.deep.equal({ balance: 'testing' }); balance = component.find('Connect(Balance)');
});
it('renders', () => {
expect(balance).to.have.length(1);
});
it('passes the account', () => {
expect(balance.props().account).to.deep.equal(ACCOUNT);
});
it('passes the balance', () => {
});
}); });
it('renders the Certifications', () => { describe('Certifications', () => {
render(); let certs;
const certs = component.find('Connect(Certifications)');
expect(certs).to.have.length(1); beforeEach(() => {
expect(certs.props().address).to.deep.equal(ACCOUNT.address); render();
certs = component.find('Connect(Certifications)');
});
it('renders', () => {
expect(certs).to.have.length(1);
});
it('passes the address', () => {
expect(certs.props().address).to.deep.equal(ACCOUNT.address);
});
}); });
it('renders the IdentityIcon', () => { describe('IdentityIcon', () => {
render(); let icon;
const icon = component.find('Connect(IdentityIcon)');
expect(icon).to.have.length(1); beforeEach(() => {
expect(icon.props().address).to.equal(ACCOUNT.address); render();
icon = component.find('Connect(IdentityIcon)');
});
it('renders', () => {
expect(icon).to.have.length(1);
});
it('passes the address', () => {
expect(icon.props().address).to.deep.equal(ACCOUNT.address);
});
}); });
it('renders the Tags', () => { describe('QrCode', () => {
render(); let qr;
const tags = component.find('Tags');
expect(tags).to.have.length(1); beforeEach(() => {
expect(tags.props().tags).to.deep.equal(ACCOUNT.meta.tags); render();
qr = component.find('QrCode');
});
it('renders', () => {
expect(qr).to.have.length(1);
});
it('passes the address', () => {
expect(qr.props().value).to.deep.equal(ACCOUNT.address);
});
});
describe('Tags', () => {
let tags;
beforeEach(() => {
render();
tags = component.find('Tags');
});
it('renders', () => {
expect(tags).to.have.length(1);
});
it('passes the tags', () => {
expect(tags.props().tags).to.deep.equal(ACCOUNT.meta.tags);
});
}); });
}); });
}); });