import React, { useContext } from 'react'
import PropTypes from 'prop-types'
import posed, { PoseGroup } from 'react-pose'
import { AppContext } from '../../store/createContext'
import { cryptoFormatter } from '../../../utils'
import stylesIndex from '../../pages/index.module.css'
import styles from './Ticker.module.css'
import { fadeIn } from '../Animations'
const Item = posed.div(fadeIn)
const Change = ({ currency }) => {
const { priceChanges } = useContext(AppContext)
const isNegative = JSON.stringify(priceChanges[currency]).startsWith('-')
let classes = isNegative ? styles.negative : styles.positive
return (
{!isNegative && '+'}
{Number(priceChanges[currency]).toFixed(1)}%
)
}
Change.propTypes = {
currency: PropTypes.string.isRequired
}
const Items = () => {
const {
prices,
needsConfig,
currency,
toggleCurrencies,
accentColor
} = useContext(AppContext)
const activeStyle = {
backgroundColor: accentColor,
color: '#fff',
borderColor: accentColor
}
// convert Map to array first, cause for...of or forEach returns
// undefined, so it cannot be mapped to a collection of elements
return [...prices.entries()].map(([key, value]) => (
-
))
}
const Ticker = props => (
)
export default Ticker