Skip to content

Commit

Permalink
feat: action buttons are now properly aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechsimetka committed Oct 5, 2021
1 parent 5e19caf commit 3be5097
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/CashoutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import DialogContentText from '@material-ui/core/DialogContentText'
import DialogTitle from '@material-ui/core/DialogTitle'
import { useSnackbar } from 'notistack'
import { ReactElement, useState, useContext } from 'react'
import { Zap } from 'react-feather'
import { Context as SettingsContext } from '../providers/Settings'
import EthereumAddress from './EthereumAddress'

Expand Down Expand Up @@ -59,8 +60,8 @@ export default function CheckoutModal({ peerId, uncashedAmount }: Props): ReactE

return (
<div>
<Button variant="contained" color="primary" onClick={handleClickOpen} style={{ marginLeft: '7px' }}>
Cashout
<Button variant="contained" onClick={handleClickOpen} startIcon={<Zap size="1rem" />}>
Cash out peer {peerId.substr(0, 8)}[…]
</Button>
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
<DialogTitle id="form-dialog-title">Cashout Cheque</DialogTitle>
Expand Down
40 changes: 40 additions & 0 deletions src/components/ExpandableListItemActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ReactElement, ReactNode } from 'react'
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'
import { Typography, Grid, IconButton, Tooltip } from '@material-ui/core'
import { Info } from 'react-feather'
import ListItem from '@material-ui/core/ListItem'

const useStyles = makeStyles((theme: Theme) =>
createStyles({
action: {
marginTop: theme.spacing(0.75),
marginRight: theme.spacing(1),
},
}),
)

interface Props {
children: ReactNode | ReactNode[]
}

export default function ExpandableListItem({ children }: Props): ReactElement | null {
const classes = useStyles()

if (Array.isArray(children)) {
return (
<Grid container direction="row">
{children.map((a, i) => (
<Grid key={i} className={classes.action}>
{a}
</Grid>
))}
</Grid>
)
}

return (
<Grid container direction="row">
<Grid className={classes.action}>{children}</Grid>
</Grid>
)
}
7 changes: 5 additions & 2 deletions src/pages/accounting/PeerBalances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ReactElement } from 'react'

import ExpandableList from '../../components/ExpandableList'
import ExpandableListItem from '../../components/ExpandableListItem'
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
import ExpandableListItemKey from '../../components/ExpandableListItemKey'

import CashoutModal from '../../components/CashoutModal'
Expand Down Expand Up @@ -37,10 +38,12 @@ export default function PeerBalances({ accounting, isLoadingUncashed, totalUncas
<ExpandableListItem label="Total" value={`${total.toFixedDecimal()} BZZ`} />
<ExpandableListItem
label="Uncashed Amount"
value={isLoadingUncashed ? 'loading...' : `${uncashedAmount.toFixedDecimal()} BZZ`}
value={isLoadingUncashed ? 'loading' : `${uncashedAmount.toFixedDecimal()} BZZ`}
/>
{uncashedAmount.toBigNumber.isGreaterThan('0') && (
<CashoutModal uncashedAmount={uncashedAmount.toFixedDecimal()} peerId={peer} />
<ExpandableListItemActions>
<CashoutModal uncashedAmount={uncashedAmount.toFixedDecimal()} peerId={peer} />
</ExpandableListItemActions>
)}
</ExpandableList>
))}
Expand Down
13 changes: 5 additions & 8 deletions src/pages/accounting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Context as SettingsContext } from '../../providers/Settings'
import { useAccounting } from '../../hooks/accounting'
import ExpandableList from '../../components/ExpandableList'
import ExpandableListItem from '../../components/ExpandableListItem'
import ExpandableListItemActions from '../../components/ExpandableListItemActions'
import ExpandableListItemKey from '../../components/ExpandableListItemKey'
import WithdrawModal from '../../containers/WithdrawModal'
import DepositModal from '../../containers/DepositModal'
Expand Down Expand Up @@ -36,14 +37,10 @@ export default function Accounting(): ReactElement {
label="Total Cheques Amount Received"
value={`${settlements?.totalReceived.toFixedDecimal()} BZZ`}
/>
<div style={{ display: 'flex', marginTop: 4 }}>
<div style={{ marginRight: 4 }}>
<WithdrawModal />
</div>
<div style={{ marginRight: 4 }}>
<DepositModal />
</div>
</div>
<ExpandableListItemActions>
<WithdrawModal />
<DepositModal />
</ExpandableListItemActions>
</ExpandableList>
<ExpandableList label="Blockchain" defaultOpen>
<ExpandableListItemKey label="Ethereum address" value={nodeAddresses?.ethereum || ''} />
Expand Down

0 comments on commit 3be5097

Please sign in to comment.