Display badges on summary view (#4689)

This commit is contained in:
Jaco Greeff 2017-02-28 16:31:22 +01:00 committed by GitHub
parent ea877cb91e
commit 4534590f39
6 changed files with 101 additions and 34 deletions

View File

@ -28,6 +28,7 @@
} }
.empty { .empty {
min-height: 24px;
line-height: 24px; line-height: 24px;
opacity: 0.25; opacity: 0.25;
overflow: hidden; overflow: hidden;

View File

@ -96,7 +96,7 @@ export default class Balance extends Component {
<div className={ styles.empty }> <div className={ styles.empty }>
<FormattedMessage <FormattedMessage
id='ui.balance.none' id='ui.balance.none'
defaultMessage='There are no balances associated with this account' defaultMessage='No balances associated with this account'
/> />
</div> </div>
); );

View File

@ -19,29 +19,40 @@
margin-top: 1em; margin-top: 1em;
} }
.certification { .certification,
.certificationIcon {
border-radius: 1em;
display: inline-block; display: inline-block;
position: relative;
margin-top: 1em;
margin-right: .5em;
padding: .3em .6em .2em 2.6em;
border-radius: 1em;
line-height: 1em; line-height: 1em;
text-transform: uppercase; position: relative;
.icon {
width: 2em;
height: 2em;
margin: 0;
padding: 0;
border-radius: 1em;
}
}
.certificationIcon {
margin-left: 0.5em;
}
.certification {
background-color: rgba(255, 255, 255, 0.07); background-color: rgba(255, 255, 255, 0.07);
} margin-right: 0.5em;
margin-top: 1em;
padding: 0.3em 0.6em 0.2em 2.6em;
text-transform: uppercase;
.certification:last-child { &:last-child {
margin-right: 0; margin-right: 0;
} }
.icon { .icon {
position: absolute; position: absolute;
top: -.25em; top: -.25em;
left: 0; left: 0;
width: 2em; }
height: 2em;
margin: 0;
padding: 0;
border-radius: 1em;
} }

View File

@ -28,7 +28,8 @@ class Certifications extends Component {
address: PropTypes.string.isRequired, address: PropTypes.string.isRequired,
certifications: PropTypes.array.isRequired, certifications: PropTypes.array.isRequired,
className: PropTypes.string, className: PropTypes.string,
dappsUrl: PropTypes.string.isRequired dappsUrl: PropTypes.string.isRequired,
showOnlyIcon: PropTypes.bool
} }
render () { render () {
@ -46,16 +47,47 @@ class Certifications extends Component {
} }
renderCertification = (certification) => { renderCertification = (certification) => {
const { name, title, icon } = certification; const { name, icon } = certification;
const { dappsUrl } = this.props; const { dappsUrl, showOnlyIcon } = this.props;
const classNames = `${styles.certification} ${!icon ? styles.noIcon : ''}`; const classNames = [
const img = icon ? dappsUrl + hashToImageUrl(icon) : defaultIcon; showOnlyIcon
? styles.certificationIcon
: styles.certification,
!icon
? styles.noIcon
: ''
];
return ( return (
<div className={ classNames } key={ name }> <div
<img className={ styles.icon } src={ img } /> className={ classNames.join(' ') }
<div className={ styles.text }>{ title || name }</div> key={ name }
>
<img
className={ styles.icon }
src={
icon
? `${dappsUrl}${hashToImageUrl(icon)}`
: defaultIcon
}
/>
{ this.renderCertificationName(certification) }
</div>
);
}
renderCertificationName = (certification) => {
const { showOnlyIcon } = this.props;
const { name, title } = certification;
if (showOnlyIcon) {
return null;
}
return (
<div className={ styles.text }>
{ title || name }
</div> </div>
); );
} }

View File

@ -144,7 +144,10 @@ class Summary extends Component {
} }
/> />
</div> </div>
{ this.renderBalance(true) } <div className={ styles.summary }>
{ this.renderBalance(true) }
{ this.renderCertifications(true) }
</div>
</Container> </Container>
); );
} }
@ -251,7 +254,7 @@ class Summary extends Component {
); );
} }
renderCertifications () { renderCertifications (onlyIcon) {
const { showCertifications, account } = this.props; const { showCertifications, account } = this.props;
if (!showCertifications) { if (!showCertifications) {
@ -261,7 +264,12 @@ class Summary extends Component {
return ( return (
<Certifications <Certifications
address={ account.address } address={ account.address }
className={ styles.Certifications } className={
onlyIcon
? styles.iconCertifications
: styles.fullCertifications
}
showOnlyIcon={ onlyIcon }
/> />
); );
} }

View File

@ -41,8 +41,19 @@
margin-top: 1.5em; margin-top: 1.5em;
} }
.ethBalances { .summary {
opacity: 1; position: relative;
.ethBalances {
opacity: 1;
}
.iconCertifications {
bottom: -0.25em;
opacity: 1;
position: absolute;
right: 0;
}
} }
.owners { .owners {
@ -71,6 +82,10 @@
.ethBalances { .ethBalances {
opacity: 0; opacity: 0;
} }
.iconCertifications {
opacity: 0;
}
} }
} }