1
0
mirror of https://github.com/kremalicious/blowfish.git synced 2024-12-28 23:57:52 +01:00

nicer first load experience

This commit is contained in:
Matthias Kretschmann 2019-05-07 00:25:31 +02:00
parent c4d071ddd0
commit 3cb5d1b5ff
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 30 additions and 24 deletions

View File

@ -86,7 +86,7 @@ button {
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
border: .1rem solid #e2e2e2; border: .1rem solid #e2e2e2;
min-height: 186px; min-height: 222px;
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;

View File

@ -22,25 +22,27 @@ export default class App extends PureComponent {
<Titlebar /> <Titlebar />
<div className="app__content"> <div className="app__content">
<Consumer> <Consumer>
{({ isLoading, accounts }) => {({ isLoading, accounts }) => (
isLoading ? ( <>
<Spinner /> <main className="main">
) : ( {isLoading ? (
<> <Spinner />
<main className="main"> ) : (
<Total /> <>
<Total />
<div className="number-unit-wrap number-unit-wrap--accounts"> <div className="number-unit-wrap number-unit-wrap--accounts">
{accounts.map((account, i) => ( {accounts.map((account, i) => (
<Account key={i} account={account} /> <Account key={i} account={account} />
))} ))}
</div> </div>
</main> </>
)}
</main>
<Ticker /> <Ticker style={isLoading ? { opacity: 0 } : null} />
</> </>
) )}
}
</Consumer> </Consumer>
</div> </div>
</AppProvider> </AppProvider>

View File

@ -1,6 +1,8 @@
.spinner { .spinner {
position: relative; position: relative;
text-align: center; text-align: center;
margin: auto;
width: 100%;
} }
.spinner::before { .spinner::before {

View File

@ -2,6 +2,7 @@
justify-content: center; justify-content: center;
margin-top: 2rem; margin-top: 2rem;
margin-bottom: 2rem; margin-bottom: 2rem;
transition: opacity 1s ease-out;
} }
.ticker .number-unit { .ticker .number-unit {

View File

@ -1,13 +1,13 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import { Consumer } from '../store/createContext' import { Consumer } from '../store/createContext'
import { userlocale } from '../util/moneyFormatter' import { locale } from '../util/moneyFormatter'
import { formatCurrency } from '@coingecko/cryptoformat' import { formatCurrency } from '@coingecko/cryptoformat'
import './Ticker.css' import './Ticker.css'
export default class Ticker extends PureComponent { export default class Ticker extends PureComponent {
render() { render() {
return ( return (
<footer className="number-unit-wrap ticker"> <footer className="number-unit-wrap ticker" {...this.props}>
<Consumer> <Consumer>
{({ toggleCurrencies, currency, prices }) => ( {({ toggleCurrencies, currency, prices }) => (
<> <>
@ -18,7 +18,7 @@ export default class Ticker extends PureComponent {
'active'}`} 'active'}`}
onClick={() => toggleCurrencies(key)} onClick={() => toggleCurrencies(key)}
> >
{formatCurrency(prices[key], key.toUpperCase(), userlocale) {formatCurrency(prices[key], key.toUpperCase(), locale)
.replace(/BTC/, 'Ƀ') .replace(/BTC/, 'Ƀ')
.replace(/ETH/, 'Ξ') .replace(/ETH/, 'Ξ')
.replace(/OCEAN/, 'Ọ')} .replace(/OCEAN/, 'Ọ')}

View File

@ -25,10 +25,11 @@ export default class AppProvider extends PureComponent {
async componentDidMount() { async componentDidMount() {
await this.fetchAndSetPrices() await this.fetchAndSetPrices()
await this.setBalances() await this.setBalances()
this.setState({ isLoading: false })
setInterval(this.fetchAndSetPrices, ms(refreshInterval)) await setInterval(this.fetchAndSetPrices, ms(refreshInterval))
setInterval(this.setBalances, ms(refreshInterval)) await setInterval(this.setBalances, ms(refreshInterval))
this.setState({ isLoading: false })
} }
componentWillUnmount() { componentWillUnmount() {