Skip to content

Commit

Permalink
TransferRow: add responsive prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
AquiGorka committed Jan 7, 2019
1 parent ed1af21 commit 85e5bb7
Showing 1 changed file with 76 additions and 6 deletions.
82 changes: 76 additions & 6 deletions apps/finance/app/src/components/TransferRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
theme,
} from '@aragon/ui'
import provideNetwork from '../lib/provideNetwork'
import { formatTokenAmount } from '../lib/utils'
import { formatTokenAmount, isSmallScreen } from '../lib/utils'
import IconTokens from './icons/IconTokens'
import ConfirmMessage from './ConfirmMessage'

Expand Down Expand Up @@ -44,7 +44,53 @@ class TransferRow extends React.Component {
showCopyTransferMessage: false,
})
}

render() {
return isSmallScreen()
? this.renderSmallScreens()
: this.renderMediumAndBiggerScreens()
}

renderSmallScreens() {
const {
network: { type },
token: { decimals, symbol },
transaction: {
date,
entity,
isIncoming,
numData: { amount },
reference,
},
} = this.props
const { showCopyTransferMessage } = this.state
const formattedAmount = formatTokenAmount(
amount,
isIncoming,
decimals,
true,
{ rounding: 5 }
)
const formattedDate = format(date, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
return (
<TableRow>
<StyledTableCell>
<Grid>
<IdentityBadge networkType={type} entity={entity} shorten={true} />
<time dateTime={formattedDate} title={formattedDate}>
{format(date, 'dd MMM yyyy')}
</time>
<TextOverflow>{reference}</TextOverflow>
<Amount positive={isIncoming}>
{formattedAmount} {symbol}
</Amount>
</Grid>
</StyledTableCell>
</TableRow>
)
}

renderMediumAndBiggerScreens() {
const { network, token, transaction, wideMode } = this.props
const { showCopyTransferMessage } = this.state
const { etherscanBaseUrl } = network
Expand Down Expand Up @@ -116,6 +162,35 @@ class TransferRow extends React.Component {
}
}

const StyledTableCell = styled(TableCell)`
&&& {
border-left: 0;
border-right: 0;
:first-child,
:last-child {
border-radius: 0;
}
}
`

const Amount = styled.span`
font-weight: 600;
color: ${({ positive }) => (positive ? theme.positive : theme.negative)};
`

const Grid = styled.div`
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
width: 100%;
padding: 0 10px;
time, ${Amount} {
text-align: right;
}
`

const NoWrapCell = styled(TableCell)`
white-space: nowrap;
`
Expand All @@ -126,11 +201,6 @@ const TextOverflow = styled.div`
text-overflow: ellipsis;
`

const Amount = styled.span`
font-weight: 600;
color: ${({ positive }) => (positive ? theme.positive : theme.negative)};
`

const ActionsWrapper = styled.div`
position: relative;
`
Expand Down

0 comments on commit 85e5bb7

Please sign in to comment.