1
0
mirror of https://github.com/trezor/trezor-wallet synced 2025-07-12 09:38:09 +00:00
trezor-wallet/src/js/components/wallet/summary/SummaryTokens.js
Szymon Lesisz 8ed54612e8 bundle
2018-03-08 17:10:53 +01:00

43 lines
1.2 KiB
JavaScript

/* @flow */
'use strict';
import React from 'react';
import ColorHash from 'color-hash';
import ScaleText from 'react-scale-text';
const SummaryTokens = (props: any): any => {
if (!props.tokens || props.tokens.length < 1) return null;
const bgColor = new ColorHash({lightness: 0.7});
const textColor = new ColorHash();
const tokens = props.tokens.map((t, i) => {
let iconColor = {
color: textColor.hex(t.name),
background: bgColor.hex(t.name),
borderColor: bgColor.hex(t.name)
}
return (
<div key={i} className="token">
<div className="icon" style={ iconColor }>
<div className="icon-inner">
<ScaleText widthOnly><p>{ t.symbol }</p></ScaleText>
</div>
</div>
<div className="name">{ t.name }</div>
<div className="balance">{ t.balance } { t.symbol }</div>
<button className="transparent" onClick={ event => props.removeToken(t) }></button>
</div>
)
});
return (
<div>
{ tokens }
</div>
)
}
export default SummaryTokens;