From 3ce7888c073a74bbac7f07541e585c9c4d42bc97 Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Tue, 24 Aug 2021 11:59:10 +0100 Subject: [PATCH] address and balance cards --- tauri-wallet/src/components/BalanceCard.tsx | 122 ++++++-------------- tauri-wallet/src/components/Nav.tsx | 1 - tauri-wallet/src/components/NymCard.tsx | 3 + tauri-wallet/src/components/Page.tsx | 11 +- 4 files changed, 47 insertions(+), 90 deletions(-) diff --git a/tauri-wallet/src/components/BalanceCard.tsx b/tauri-wallet/src/components/BalanceCard.tsx index 65116de259..0807a74a00 100644 --- a/tauri-wallet/src/components/BalanceCard.tsx +++ b/tauri-wallet/src/components/BalanceCard.tsx @@ -1,98 +1,46 @@ import React, { useContext } from 'react' -import { makeStyles } from '@material-ui/core/styles' -import { - Card, - CardMedia, - CardContent, - Typography, - CardHeader, - IconButton, -} from '@material-ui/core' -import logo from '../images/logo.png' -import { theme } from '../theme' +import { CardContent, IconButton, useTheme } from '@material-ui/core' import { ClientContext } from '../context/main' import { FileCopy, Refresh } from '@material-ui/icons' +import { NymCard } from './NymCard' -const useStyles = makeStyles(({ spacing }) => ({ - root: { - margin: spacing(10, 5, 3, 7), - borderRadius: spacing(2), // 16px - display: 'flex', - flexDirection: 'row', - alignItems: 'center', - paddingBottom: spacing(2), - paddingTop: spacing(2), - minWidth: 300, - position: 'relative', - }, -})) - -export const BalanceCard = React.memo(function BlogCard() { - const styles = useStyles() +export const BalanceCard = () => { + const theme = useTheme() const { client } = useContext(ClientContext) - return ( - - - - - - } - /> - - - - } - lastChild - /> - - - ) -}) -const BalanceCardField = ({ - primaryText, - subText, - Action, - lastChild, -}: { - primaryText: string - subText: string - Action?: React.ReactNode - lastChild?: boolean -}) => { return ( -
- - {primaryText} - -
+ + + + } > - - {subText} - - {Action} -
+ {client.balance} + +
+ ) +} + +export const AddressCard = () => { + const theme = useTheme() + const { client } = useContext(ClientContext) + return ( +
+ + + + } + > + {client.address} +
) } diff --git a/tauri-wallet/src/components/Nav.tsx b/tauri-wallet/src/components/Nav.tsx index f0c1a564b1..9c6678192c 100644 --- a/tauri-wallet/src/components/Nav.tsx +++ b/tauri-wallet/src/components/Nav.tsx @@ -84,7 +84,6 @@ export const Nav = () => { display: 'flex', alignItems: 'center', justifyContent: 'center', - marginTop: theme.spacing(6), }} > diff --git a/tauri-wallet/src/components/NymCard.tsx b/tauri-wallet/src/components/NymCard.tsx index a73d0866dd..3ba0820662 100644 --- a/tauri-wallet/src/components/NymCard.tsx +++ b/tauri-wallet/src/components/NymCard.tsx @@ -4,11 +4,13 @@ import { Card, CardContent, CardHeader, useTheme } from '@material-ui/core' export const NymCard = ({ title, subheader, + Action, noPadding, children, }: { title: string subheader?: string + Action?: React.ReactNode noPadding?: boolean children: React.ReactElement }) => { @@ -20,6 +22,7 @@ export const NymCard = ({ subheader={subheader} titleTypographyProps={{ variant: 'h5' }} subheaderTypographyProps={{ variant: 'subtitle1' }} + action={Action} style={{ padding: theme.spacing(2.5), borderBottom: `1px solid ${theme.palette.grey[200]}`, diff --git a/tauri-wallet/src/components/Page.tsx b/tauri-wallet/src/components/Page.tsx index 198da00e08..4f9ee67ee1 100644 --- a/tauri-wallet/src/components/Page.tsx +++ b/tauri-wallet/src/components/Page.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { BalanceCard } from './BalanceCard' +import { AddressCard, BalanceCard } from './BalanceCard' import { Nav } from './Nav' import Logo from '../images/logo.png' import { theme } from '../theme' @@ -44,7 +44,14 @@ export const Page = ({ children }: { children: React.ReactElement }) => { marginTop: theme.spacing(6), }} /> -