From d6a45ed65b4f86cd4342254f5158e397e5afe65f Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 20 Feb 2018 11:59:50 +0100 Subject: [PATCH] Use the common currencies icons instead of local ones --- src/components/DashboardPage/AccountCard.js | 76 +++++++++++---------- src/components/SideBar/index.js | 45 ++++++------ src/components/TransactionsList/index.js | 6 +- src/icons/currencies/Bitcoin.js | 10 --- 4 files changed, 66 insertions(+), 71 deletions(-) delete mode 100644 src/icons/currencies/Bitcoin.js diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js index c5089370..a133c245 100644 --- a/src/components/DashboardPage/AccountCard.js +++ b/src/components/DashboardPage/AccountCard.js @@ -1,11 +1,10 @@ // @flow import React from 'react' +import { getIconByCoinType } from '@ledgerhq/currencies/react' import type { Account } from 'types/common' -import IconCurrencyBitcoin from 'icons/currencies/Bitcoin' - import { AreaChart } from 'components/base/Chart' import Bar from 'components/base/Bar' import Box, { Card } from 'components/base/Box' @@ -19,43 +18,46 @@ const AccountCard = ({ account: Account, data: Array, onClick: Function, -}) => ( - - - - - - - - {account.unit.code} +}) => { + const Icon = getIconByCoinType(account.currency.coinType) + return ( + + + + {Icon && } - - {account.name} + + + {account.unit.code} + + + {account.name} + - - - - {account.data && ( - - )} - - - -) + + + {account.data && ( + + )} + + + + ) +} export default AccountCard diff --git a/src/components/SideBar/index.js b/src/components/SideBar/index.js index 05f7456f..f8924170 100644 --- a/src/components/SideBar/index.js +++ b/src/components/SideBar/index.js @@ -5,6 +5,7 @@ import { compose } from 'redux' import { translate } from 'react-i18next' import styled from 'styled-components' import { connect } from 'react-redux' +import { getIconByCoinType } from '@ledgerhq/currencies/react' import { MODAL_SEND, MODAL_RECEIVE, MODAL_ADD_ACCOUNT } from 'constants' @@ -19,7 +20,6 @@ import IconArrowDown from 'icons/ArrowDown' import IconArrowUp from 'icons/ArrowUp' import IconSettings from 'icons/Settings' import IconPlus from 'icons/Plus' -import IconCurrencyBitcoin from 'icons/currencies/Bitcoin' import Box, { Tabbable } from 'components/base/Box' import FormattedVal from 'components/base/FormattedVal' @@ -99,26 +99,29 @@ class SideBar extends PureComponent { - {accounts.map(account => ( - - } - iconActiveColor="#fcb653" - icon={} - key={account.id} - linkTo={`/account/${account.id}`} - > - {account.name} - - ))} + {accounts.map(account => { + const Icon = getIconByCoinType(account.currency.coinType) + return ( + + } + iconActiveColor={account.currency.color} + icon={Icon ? : null} + key={account.id} + linkTo={`/account/${account.id}`} + > + {account.name} + + ) + })} diff --git a/src/components/TransactionsList/index.js b/src/components/TransactionsList/index.js index 665d8851..02c79858 100644 --- a/src/components/TransactionsList/index.js +++ b/src/components/TransactionsList/index.js @@ -6,6 +6,7 @@ import moment from 'moment' import get from 'lodash/get' import noop from 'lodash/noop' import isEqual from 'lodash/isEqual' +import { getIconByCoinType } from '@ledgerhq/currencies/react' import type { Transaction as TransactionType } from 'types/common' @@ -14,8 +15,6 @@ import Defer from 'components/base/Defer' import FormattedVal from 'components/base/FormattedVal' import Text from 'components/base/Text' -import IconCurrencyBitcoin from 'icons/currencies/Bitcoin' - const DATE_COL_SIZE = 80 const ACCOUNT_COL_SIZE = 150 const AMOUNT_COL_SIZE = 150 @@ -79,6 +78,7 @@ const Transaction = ({ tx: TransactionType, }) => { const time = moment(tx.received_at) + const Icon = getIconByCoinType(tx.account.currency.coinType) return ( @@ -96,7 +96,7 @@ const Transaction = ({ onClick={() => onAccountClick && onAccountClick(tx.account)} > - + {Icon && } {tx.account.name} diff --git a/src/icons/currencies/Bitcoin.js b/src/icons/currencies/Bitcoin.js deleted file mode 100644 index 9da6bfb6..00000000 --- a/src/icons/currencies/Bitcoin.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react' - -export default props => ( - - - -)