refactor: reduce styling boilerplate

This commit is contained in:
José Oliveira 2021-07-06 15:22:15 +01:00
parent 4b5ca48190
commit 24a1ca84a6

View file

@ -15,21 +15,20 @@ import { H4, Label2, P, Info2 } from 'src/components/typography'
import styles from './Assets.styles' import styles from './Assets.styles'
const useStyles = makeStyles(styles) const useStyles = makeStyles(styles)
const Cell = withStyles({ const cellStyling = {
root: {
borderBottom: '4px solid white', borderBottom: '4px solid white',
padding: 0, padding: 0,
paddingLeft: 20, paddingLeft: 20,
paddingRight: 20 paddingRight: 20
} }
const Cell = withStyles({
root: cellStyling
})(TableCell) })(TableCell)
const HeaderCell = withStyles({ const HeaderCell = withStyles({
root: { root: {
borderBottom: '4px solid white', ...cellStyling,
padding: 0,
paddingLeft: 20,
paddingRight: 20,
backgroundColor: 'white' backgroundColor: 'white'
} }
})(TableCell) })(TableCell)
@ -64,7 +63,7 @@ const AssetsAmountTable = ({ title, data = [], numToRender }) => {
</TableHead> </TableHead>
<TableBody> <TableBody>
{data?.map((asset, idx) => { {data?.map((asset, idx) => {
if (idx < numToRender) { if (!(idx < numToRender)) return <></>
return ( return (
<TableRow className={classes.row} key={idx}> <TableRow className={classes.row} key={idx}>
<Cell align="left"> <Cell align="left">
@ -78,8 +77,6 @@ const AssetsAmountTable = ({ title, data = [], numToRender }) => {
</Cell> </Cell>
</TableRow> </TableRow>
) )
}
return null
})} })}
<TableRow className={classes.totalRow} key={data?.length + 1}> <TableRow className={classes.totalRow} key={data?.length + 1}>
<Cell align="left"> <Cell align="left">