mirror of
https://github.com/kremalicious/blowfish.git
synced 2024-12-29 16:17:52 +01:00
make touchbar work
This commit is contained in:
parent
a5d5022688
commit
8b3d0df203
@ -1,34 +1,49 @@
|
|||||||
import React, { PureComponent } from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { TouchBar, Button } from 'react-touchbar-electron'
|
import { TouchBar, Button } from 'react-touchbar-electron'
|
||||||
import { locale } from '../util/moneyFormatter'
|
import { locale } from '../util/moneyFormatter'
|
||||||
import { formatCurrency } from '@coingecko/cryptoformat'
|
import { formatCurrency } from '@coingecko/cryptoformat'
|
||||||
import { AppContext } from '../store/createContext'
|
import { AppContext } from '../store/createContext'
|
||||||
|
|
||||||
export default class Touchbar extends PureComponent {
|
const TouchbarItems = ({ prices, currency, toggleCurrencies }) => (
|
||||||
items = (
|
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
label={formatCurrency(1, 'OCEAN', locale).replace(/OCEAN/, 'Ọ')}
|
label={formatCurrency(1, 'OCEAN', locale).replace(/OCEAN/, 'Ọ')}
|
||||||
onClick={() => this.context.toggleCurrencies('ocean')}
|
onClick={() => toggleCurrencies('ocean')}
|
||||||
|
backgroundColor={currency === 'ocean' ? '#f6388a' : '#141414'}
|
||||||
/>
|
/>
|
||||||
{Object.keys(this.context.prices).map(key => (
|
{Object.keys(prices).map(key => (
|
||||||
<Button
|
<Button
|
||||||
key={key}
|
key={key}
|
||||||
label={formatCurrency(
|
label={formatCurrency(prices[key], key.toUpperCase(), locale)
|
||||||
this.context.prices[key],
|
|
||||||
key.toUpperCase(),
|
|
||||||
locale
|
|
||||||
)
|
|
||||||
.replace(/BTC/, 'Ƀ')
|
.replace(/BTC/, 'Ƀ')
|
||||||
.replace(/ETH/, 'Ξ')}
|
.replace(/ETH/, 'Ξ')}
|
||||||
onClick={() => this.context.toggleCurrencies(key)}
|
onClick={() => toggleCurrencies(key)}
|
||||||
|
backgroundColor={
|
||||||
|
currency !== 'ocean' && currency === key ? '#f6388a' : '#141414'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TouchbarItems.propTypes = {
|
||||||
|
prices: PropTypes.object.isRequired,
|
||||||
|
currency: PropTypes.string.isRequired,
|
||||||
|
toggleCurrencies: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Touchbar extends PureComponent {
|
||||||
render() {
|
render() {
|
||||||
return <TouchBar>{this.items}</TouchBar>
|
return (
|
||||||
|
<TouchBar>
|
||||||
|
<TouchbarItems
|
||||||
|
prices={this.context.prices}
|
||||||
|
currency={this.context.currency}
|
||||||
|
toggleCurrencies={this.context.toggleCurrencies}
|
||||||
|
/>
|
||||||
|
</TouchBar>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user