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": {
"message": "Paste your seed phrase here!"
},
"pending": {
"message": "Pending"
},
"personalAddressDetected": {
"message": "Personal address detected. Input the token contract address."
},
@ -736,6 +733,9 @@
"qrCode": {
"message": "Show QR Code"
},
"queue": {
"message": "Queue"
},
"readdToken": {
"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": {
"message": "Send ETH"
},
"sendEther": {
"message": "Send Ether"
},
"sendTokens": {
"message": "Send Tokens"
},
@ -919,6 +916,9 @@
"orderOneHere": {
"message": "Order a Trezor or Ledger and keep your funds in cold storage"
},
"outgoing": {
"message": "Outgoing"
},
"searchTokens": {
"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',
style: {
height: diameter,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,8 +11,8 @@ export const TOKEN_METHOD_TRANSFER = 'transfer'
export const TOKEN_METHOD_APPROVE = 'approve'
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 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'

View File

@ -9,7 +9,7 @@ const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR)
// formatData :: ( date: <Unix Timestamp> ) -> String
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 = {