From 09e48b4cbcf27f66e2df770cb95c6e32e95271d7 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 20 May 2019 20:53:32 +0200 Subject: [PATCH] consistent number formatting based on system locale --- src/app/components/Balance.jsx | 10 +++----- src/app/components/Ticker.jsx | 10 +++----- src/app/components/Touchbar.js | 9 +++----- src/app/util/moneyFormatter.js | 9 -------- src/utils.js | 42 ++++++++++++++++++++++++++++++++-- 5 files changed, 49 insertions(+), 31 deletions(-) delete mode 100644 src/app/util/moneyFormatter.js diff --git a/src/app/components/Balance.jsx b/src/app/components/Balance.jsx index cff92b3..12019c9 100644 --- a/src/app/components/Balance.jsx +++ b/src/app/components/Balance.jsx @@ -1,9 +1,8 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' -import { AppContext } from '../store/createContext' -import { locale } from '../util/moneyFormatter' -import { formatCurrency } from '@coingecko/cryptoformat' import posed, { PoseGroup } from 'react-pose' +import { AppContext } from '../store/createContext' +import { cryptoFormatter } from '../../utils' import './Balance.css' import { fadeIn } from './Animations' @@ -23,10 +22,7 @@ export default class Balance extends PureComponent { return ( - {formatCurrency(balance[currency], currency.toUpperCase(), locale) - .replace(/BTC/, 'Ƀ') - .replace(/ETH/, 'Ξ') - .replace(/OCEAN/, 'Ọ')} + {cryptoFormatter(balance[currency], currency)} ) diff --git a/src/app/components/Ticker.jsx b/src/app/components/Ticker.jsx index 2cbefb8..5c68820 100644 --- a/src/app/components/Ticker.jsx +++ b/src/app/components/Ticker.jsx @@ -1,8 +1,7 @@ import React, { PureComponent } from 'react' -import { AppContext } from '../store/createContext' -import { locale } from '../util/moneyFormatter' -import { formatCurrency } from '@coingecko/cryptoformat' import posed, { PoseGroup } from 'react-pose' +import { AppContext } from '../store/createContext' +import { cryptoFormatter } from '../../utils' import './Ticker.css' import { fadeIn } from './Animations' @@ -37,10 +36,7 @@ export default class Ticker extends PureComponent { disabled={needsConfig} style={key === currency && !needsConfig ? activeStyle : {}} > - {formatCurrency(prices[key], key.toUpperCase(), locale) - .replace(/BTC/, 'Ƀ') - .replace(/ETH/, 'Ξ') - .replace(/OCEAN/, 'Ọ')} + {cryptoFormatter(prices[key], key)} ))} diff --git a/src/app/components/Touchbar.js b/src/app/components/Touchbar.js index 111af8b..9d8d923 100644 --- a/src/app/components/Touchbar.js +++ b/src/app/components/Touchbar.js @@ -1,23 +1,20 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import { TouchBar, Button } from 'react-touchbar-electron' -import { locale } from '../util/moneyFormatter' -import { formatCurrency } from '@coingecko/cryptoformat' +import { cryptoFormatter } from '../../utils' import { AppContext } from '../store/createContext' const TouchbarItems = ({ prices, currency, toggleCurrencies, accentColor }) => ( <>