CryptoDonate: refactor CryptoIcon into its own component
This commit is contained in:
parent
850fd6d310
commit
5166a71c27
4 changed files with 38 additions and 12 deletions
|
@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
|
|||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import Icon from 'soapbox/components/icon';
|
||||
import CoinDB from '../utils/coin_db';
|
||||
import { getCoinIcon } from '../utils/coin_icons';
|
||||
import CryptoIcon from './crypto_icon';
|
||||
import { openModal } from 'soapbox/actions/modal';
|
||||
import { CopyableInput } from 'soapbox/features/forms';
|
||||
import { getExplorerUrl } from '../utils/block_explorer';
|
||||
|
@ -31,9 +31,11 @@ class CryptoAddress extends ImmutablePureComponent {
|
|||
return (
|
||||
<div className='crypto-address'>
|
||||
<div className='crypto-address__head'>
|
||||
<div className='crypto-address__icon'>
|
||||
<img src={getCoinIcon(ticker)} alt={title} />
|
||||
</div>
|
||||
<CryptoIcon
|
||||
className='crypto-address__icon'
|
||||
ticker={ticker}
|
||||
title={title}
|
||||
/>
|
||||
<div className='crypto-address__title'>{title || ticker.toUpperCase()}</div>
|
||||
<div className='crypto-address__actions'>
|
||||
<a href='' onClick={this.handleModalClick}>
|
||||
|
|
26
app/soapbox/features/crypto_donate/components/crypto_icon.js
Normal file
26
app/soapbox/features/crypto_donate/components/crypto_icon.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export default class CryptoIcon extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
ticker: PropTypes.string.isRequired,
|
||||
title: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
}
|
||||
|
||||
render() {
|
||||
const { ticker, title, className } = this.props;
|
||||
|
||||
return (
|
||||
<div className={classNames('crypto-icon', className)}>
|
||||
<img
|
||||
src={require(`cryptocurrency-icons/svg/color/${ticker.toLowerCase()}.svg`)}
|
||||
alt={title || ticker}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
import Icon from 'soapbox/components/icon';
|
||||
import QRCode from 'qrcode.react';
|
||||
import CoinDB from '../utils/coin_db';
|
||||
import { getCoinIcon } from '../utils/coin_icons';
|
||||
import CryptoIcon from './crypto_icon';
|
||||
import { CopyableInput } from 'soapbox/features/forms';
|
||||
import { getExplorerUrl } from '../utils/block_explorer';
|
||||
|
||||
|
@ -26,9 +26,11 @@ class DetailedCryptoAddress extends ImmutablePureComponent {
|
|||
return (
|
||||
<div className='crypto-address'>
|
||||
<div className='crypto-address__head'>
|
||||
<div className='crypto-address__icon'>
|
||||
<img src={getCoinIcon(ticker)} alt={title} />
|
||||
</div>
|
||||
<CryptoIcon
|
||||
className='crypto-address__icon'
|
||||
ticker={ticker}
|
||||
title={title}
|
||||
/>
|
||||
<div className='crypto-address__title'>{title || ticker.toUpperCase()}</div>
|
||||
<div className='crypto-address__actions'>
|
||||
{explorerUrl && <a href={explorerUrl} target='_blank'>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
// For getting the icon
|
||||
export const getCoinIcon = ticker => {
|
||||
return require(`cryptocurrency-icons/svg/color/${ticker.toLowerCase()}.svg`);
|
||||
};
|
Loading…
Reference in a new issue