1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Use css grid for TransactionListItem for responsive layout

This commit is contained in:
Alexander Tseung 2018-07-31 19:37:38 -07:00
parent 01f00a9ca6
commit 5de48c67a0
9 changed files with 96 additions and 74 deletions

View File

@ -705,9 +705,6 @@
"pasteSeed": { "pasteSeed": {
"message": "Paste your seed phrase here!" "message": "Paste your seed phrase here!"
}, },
"pending": {
"message": "Pending"
},
"personalAddressDetected": { "personalAddressDetected": {
"message": "Personal address detected. Input the token contract address." "message": "Personal address detected. Input the token contract address."
}, },
@ -736,6 +733,9 @@
"qrCode": { "qrCode": {
"message": "Show QR Code" "message": "Show QR Code"
}, },
"queue": {
"message": "Queue"
},
"readdToken": { "readdToken": {
"message": "You can add this token back in the future by going go to “Add token” in your accounts options menu." "message": "You can add this token back in the future by going go to “Add token” in your accounts options menu."
}, },
@ -900,9 +900,6 @@
"sendETH": { "sendETH": {
"message": "Send ETH" "message": "Send ETH"
}, },
"sendEther": {
"message": "Send Ether"
},
"sendTokens": { "sendTokens": {
"message": "Send Tokens" "message": "Send Tokens"
}, },
@ -919,6 +916,9 @@
"orderOneHere": { "orderOneHere": {
"message": "Order a Trezor or Ledger and keep your funds in cold storage" "message": "Order a Trezor or Ledger and keep your funds in cold storage"
}, },
"outgoing": {
"message": "Outgoing"
},
"searchTokens": { "searchTokens": {
"message": "Search Tokens" "message": "Search Tokens"
}, },

View File

@ -47,7 +47,8 @@ IdenticonComponent.prototype.render = function () {
}) })
) )
: ( : (
h('img.balance-icon', { h('img', {
className: `${className} balance-icon`,
src: './images/eth_logo.svg', src: './images/eth_logo.svg',
style: { style: {
height: diameter, height: diameter,

View File

@ -1,41 +1,51 @@
.transaction-list-item { .transaction-list-item {
box-sizing: border-box; box-sizing: border-box;
height: 74px; min-height: 74px;
padding: 0 21px; padding: 8px 20px;
display: flex; display: grid;
flex-direction: row; grid-template-columns: 45px 1fr 1fr 1fr;
align-items: center; grid-template-areas:
"identicon action status primary-amount"
"identicon nonce status secondary-amount";
border-bottom: 1px solid $geyser; border-bottom: 1px solid $geyser;
cursor: pointer; cursor: pointer;
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
padding: 0 12px; padding: 8px 20px 12px;
grid-template-columns: 45px 5fr 3fr;
grid-template-areas:
"nonce nonce nonce"
"identicon action primary-amount"
"identicon status secondary-amount";
} }
&__identicon-wrapper { &__identicon {
padding-top: 2px; grid-area: identicon;
} grid-row: 1 / span 2;
align-self: center;
&__action-block {
padding: 0 8px 0 12px;
width: 180px;
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
padding: 0 8px; grid-row: 2 / span 2;
width: 160px;
} }
} }
&__action { &__action {
text-transform: capitalize; text-transform: capitalize;
padding-bottom: 2px; padding: 0 8px 2px 0;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
grid-area: action;
align-self: end;
}
&__status {
grid-area: status;
grid-row: 1 / span 2;
align-self: center;
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
padding-bottom: 0; grid-row: 3;
font-size: .875rem;
} }
} }
@ -45,26 +55,39 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} grid-area: nonce;
align-self: start;
&__transaction-amounts {
flex: 1;
}
&__primary-transaction-amount {
text-align: end;
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
font-size: .75rem; padding-bottom: 4px;
} }
} }
&__secondary-transaction-amount { &__amount {
text-align: end; white-space: nowrap;
font-size: .75rem; overflow: hidden;
color: #5e6064; text-overflow: ellipsis;
&--primary {
text-align: end;
grid-area: primary-amount;
align-self: end;
@media screen and (max-width: $break-small) {
padding-bottom: 2px;
}
}
&--secondary {
text-align: end;
font-size: .75rem;
color: #5e6064;
grid-area: secondary-amount;
align-self: start;
}
} }
&:hover { &:hover {
background: rgba($alto, .2); background: rgba($alto, .2);
} }

View File

@ -1,6 +1,5 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Media from 'react-media'
import Identicon from '../identicon' import Identicon from '../identicon'
import TransactionStatus from '../transaction-status' import TransactionStatus from '../transaction-status'
import TransactionAction from '../transaction-action' import TransactionAction from '../transaction-action'
@ -46,35 +45,33 @@ export default class TransactionListItem extends PureComponent {
className="transaction-list-item" className="transaction-list-item"
onClick={this.handleClick} onClick={this.handleClick}
> >
<div className="transaction-list-item__identicon-wrapper"> <Identicon
<Media query="(max-width: 575px)"> className="transaction-list-item__identicon"
{ address={txParams.to}
matches => ( diameter={34}
<Identicon />
address={txParams.to} <TransactionAction
diameter={matches ? 26 : 34} transaction={transaction}
/> className="transaction-list-item__action"
) />
} <div className="transaction-list-item__nonce">
</Media> { `#${nonce} - ${formatDate(transaction.time)}` }
</div> </div>
<div className="transaction-list-item__action-block"> <TransactionStatus
<TransactionAction className="transaction-list-item__status"
transaction={transaction} status={transaction.status}
className="transaction-list-item__action" />
/> <div
<div className="transaction-list-item__nonce"> className="transaction-list-item__amount transaction-list-item__amount--primary"
{ `#${nonce} - ${formatDate(transaction.time)}` } title={`-${fiatDisplayValue}`}
</div> >
{ `-${fiatDisplayValue}` }
</div> </div>
<TransactionStatus status={transaction.status} /> <div
<div className="transaction-list-item__transaction-amounts"> className="transaction-list-item__amount transaction-list-item__amount--secondary"
<div className="transaction-list-item__primary-transaction-amount"> title={`-${ethTransactionAmount} ETH`}
{ `-${fiatDisplayValue}` } >
</div> { `-${ethTransactionAmount} ETH` }
<div className="transaction-list-item__secondary-transaction-amount">
{ `-${ethTransactionAmount} ETH` }
</div>
</div> </div>
</div> </div>
) )

View File

@ -27,7 +27,7 @@ export default class TransactionList extends PureComponent {
pendingTransactions.length > 0 && ( pendingTransactions.length > 0 && (
<div className="transaction-list__pending-transactions"> <div className="transaction-list__pending-transactions">
<div className="transaction-list__header"> <div className="transaction-list__header">
{ `${t('pending')} (${pendingTransactions.length})` } { `${t('queue')} (${pendingTransactions.length})` }
</div> </div>
{ {
pendingTransactions.map(transaction => { pendingTransactions.map(transaction => {

View File

@ -11,8 +11,8 @@
align-items: center; align-items: center;
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
height: 24px; height: 16px;
width: 74px; width: 70px;
font-size: .5rem; font-size: .5rem;
} }

View File

@ -30,13 +30,14 @@ const statusToTextHash = {
export default class TransactionStatus extends PureComponent { export default class TransactionStatus extends PureComponent {
static propTypes = { static propTypes = {
status: PropTypes.string, status: PropTypes.string,
className: PropTypes.string,
} }
render () { render () {
const { status } = this.props const { className, status } = this.props
return ( return (
<div className={classnames('transaction-status', statusToClassNameHash[status])}> <div className={classnames('transaction-status', className, statusToClassNameHash[status])}>
{ statusToTextHash[status] || status } { statusToTextHash[status] || status }
</div> </div>
) )

View File

@ -11,8 +11,8 @@ export const TOKEN_METHOD_TRANSFER = 'transfer'
export const TOKEN_METHOD_APPROVE = 'approve' export const TOKEN_METHOD_APPROVE = 'approve'
export const TOKEN_METHOD_TRANSFER_FROM = 'transferfrom' export const TOKEN_METHOD_TRANSFER_FROM = 'transferfrom'
export const SEND_ETHER_ACTION_KEY = 'sendEther' export const SEND_ETHER_ACTION_KEY = 'outgoing'
export const DEPLOY_CONTRACT_ACTION_KEY = 'contractDeployment' export const DEPLOY_CONTRACT_ACTION_KEY = 'contractDeployment'
export const APPROVE_ACTION_KEY = 'approve' export const APPROVE_ACTION_KEY = 'approve'
export const SEND_TOKEN_ACTION_KEY = 'sendToken' export const SEND_TOKEN_ACTION_KEY = 'outgoing'
export const TRANSFER_FROM_ACTION_KEY = 'transferFrom' export const TRANSFER_FROM_ACTION_KEY = 'transferFrom'

View File

@ -9,7 +9,7 @@ const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
// formatData :: ( date: <Unix Timestamp> ) -> String // formatData :: ( date: <Unix Timestamp> ) -> String
function formatDate (date) { function formatDate (date) {
return vreme.format(new Date(date), 'March 16 2014 14:30') return vreme.format(new Date(date), 'March 16 2014, at 14:30')
} }
var valueTable = { var valueTable = {