mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-15 21:08:57 +00:00
Create component for displaying a coin logo image
This commit is contained in:
parent
96b5b9058b
commit
69562c6d7a
41
src/js/components/CoinLogo/index.js
Normal file
41
src/js/components/CoinLogo/index.js
Normal file
@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ICON_SIZE } from 'config/variables';
|
||||
|
||||
const Logo = styled.div`
|
||||
height: ${ICON_SIZE.BASE};
|
||||
width: ${ICON_SIZE.BASE};
|
||||
margin-right: 5px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: auto ${ICON_SIZE.BASE};
|
||||
background-image: url('${props => props.coinImg}');
|
||||
`;
|
||||
|
||||
const CoinLogo = ({
|
||||
className, coinNetwork, coinImg,
|
||||
}) => {
|
||||
let coinImgName = coinNetwork;
|
||||
if (coinImgName === 'ethereum') {
|
||||
coinImgName = 'eth';
|
||||
} else if (coinImgName === 'ethereum-classic') {
|
||||
coinImgName = 'etc';
|
||||
}
|
||||
const coinImgUrl = `../images/${coinImgName}-logo.png`;
|
||||
|
||||
return (
|
||||
<Logo
|
||||
className={className}
|
||||
coinImg={coinImg || coinImgUrl}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
CoinLogo.propTypes = {
|
||||
className: PropTypes.string,
|
||||
coinImg: PropTypes.string,
|
||||
coinNetwork: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CoinLogo;
|
Loading…
Reference in New Issue
Block a user