blowfish/src/app/components/Ticker.jsx

52 lines
1.4 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react'
2019-05-08 21:41:24 +02:00
import { AppContext } from '../store/createContext'
2019-05-07 00:25:31 +02:00
import { locale } from '../util/moneyFormatter'
import { formatCurrency } from '@coingecko/cryptoformat'
2019-05-11 20:16:18 +02:00
import posed, { PoseGroup } from 'react-pose'
import './Ticker.css'
2019-05-11 20:16:18 +02:00
import { fadeIn } from './Animations'
const Item = posed.div(fadeIn)
export default class Ticker extends PureComponent {
2019-05-10 00:37:59 +02:00
static contextType = AppContext
render() {
const {
toggleCurrencies,
needsConfig,
currency,
prices,
accentColor
} = this.context
const activeStyle = {
backgroundColor: accentColor,
color: '#fff',
borderColor: accentColor
}
2019-05-10 00:37:59 +02:00
return (
2019-05-07 00:25:31 +02:00
<footer className="number-unit-wrap ticker" {...this.props}>
2019-05-11 20:16:18 +02:00
<PoseGroup animateOnMount>
{Object.keys(prices).map((key, i) => (
<Item key={i} className="number-unit">
<button
className="label label--price"
2019-05-11 20:16:18 +02:00
onClick={() => toggleCurrencies(key)}
disabled={needsConfig}
style={key === currency && !needsConfig ? activeStyle : {}}
2019-05-11 20:16:18 +02:00
>
{formatCurrency(prices[key], key.toUpperCase(), locale)
.replace(/BTC/, 'Ƀ')
.replace(/ETH/, 'Ξ')
.replace(/OCEAN/, 'Ọ')}
</button>
</Item>
))}
</PoseGroup>
</footer>
)
}
}