blowfish/src/renderer/screens/Home/index.jsx

56 lines
1.3 KiB
React
Raw Normal View History

2019-09-08 21:47:57 +02:00
import React, { useContext } from 'react'
import { Link } from '@reach/router'
import classnames from 'classnames'
import { AppContext } from '../../store/createContext'
import Welcome from '../../components/Welcome'
import Spinner from '../../components/Spinner'
import Divider from '../../components/Divider'
import Total from './Total'
import Account from './Account'
import Ticker from './Ticker'
import IconCog from '../../images/cog.svg'
2019-09-09 00:13:38 +02:00
import stylesBox from '../../components/Box.module.css'
2019-09-08 21:47:57 +02:00
import styles from './index.module.css'
const Accounts = () => {
const { accounts } = useContext(AppContext)
return (
<div className={styles.balanceWrapAccounts}>
{accounts.map((account, i) => (
<Account key={i} account={account} />
))}
</div>
)
}
const Home = () => {
const { isLoading, needsConfig } = useContext(AppContext)
return (
<>
2019-09-09 00:13:38 +02:00
<main className={classnames(styles.main, stylesBox.box)}>
2019-09-08 21:47:57 +02:00
<Link className={styles.preferences} to="/preferences">
<IconCog />
</Link>
{needsConfig ? (
<Welcome />
) : isLoading ? (
<Spinner />
) : (
<>
<Total />
<Divider />
<Accounts />
</>
)}
</main>
<Ticker style={isLoading ? { opacity: 0 } : null} />
</>
)
}
export default Home