mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Create tx-list-item component.
This commit is contained in:
parent
6d3b3d4203
commit
17b5afb8de
92
ui/app/components/tx-list-item.js
Normal file
92
ui/app/components/tx-list-item.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
const Component = require('react').Component
|
||||||
|
const h = require('react-hyperscript')
|
||||||
|
const inherits = require('util').inherits
|
||||||
|
const Identicon = require('./identicon')
|
||||||
|
|
||||||
|
module.exports = TxListItem
|
||||||
|
|
||||||
|
inherits(TxListItem, Component)
|
||||||
|
function TxListItem () {
|
||||||
|
Component.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
TxListItem.prototype.getAddressText = function (address) {
|
||||||
|
return address
|
||||||
|
? `${address.slice(0, 10)}...${address.slice(-4)}`
|
||||||
|
: 'Contract Published'
|
||||||
|
}
|
||||||
|
|
||||||
|
TxListItem.prototype.render = function () {
|
||||||
|
const {
|
||||||
|
transactionStatus,
|
||||||
|
onClick,
|
||||||
|
transActionId,
|
||||||
|
dateString,
|
||||||
|
address,
|
||||||
|
transactionAmount,
|
||||||
|
className
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
return h(`div${className || ''}`, {
|
||||||
|
key: transActionId,
|
||||||
|
onClick: () => onClick && onClick(transActionId),
|
||||||
|
}, [
|
||||||
|
h(`div.flex-column.tx-list-item-wrapper`, {}, [
|
||||||
|
|
||||||
|
h('div.tx-list-date-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
h('span.tx-list-date', {}, [
|
||||||
|
dateString,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div.flex-row.tx-list-content-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
|
||||||
|
h('div.tx-list-identicon-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
h(Identicon, {
|
||||||
|
address,
|
||||||
|
diameter: 28,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div.tx-list-account-and-status-wrapper', {}, [
|
||||||
|
h('div.tx-list-account-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
h('span.tx-list-account', {}, [
|
||||||
|
this.getAddressText(address),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div.tx-list-status-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
h('span.tx-list-status', {}, [
|
||||||
|
transactionStatus,
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div.flex-column.tx-list-details-wrapper', {
|
||||||
|
style: {},
|
||||||
|
}, [
|
||||||
|
|
||||||
|
h('span.tx-list-value', {}, [
|
||||||
|
transactionAmount,
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('span.tx-list-fiat-value', {}, [
|
||||||
|
'+ $300 USD',
|
||||||
|
]),
|
||||||
|
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]) // holding on icon from design
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ const connect = require('react-redux').connect
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const selectors = require('../selectors')
|
const selectors = require('../selectors')
|
||||||
const Identicon = require('./identicon')
|
const TxListItem = require('./tx-list-item')
|
||||||
const { formatBalance, formatDate } = require('../util')
|
const { formatBalance, formatDate } = require('../util')
|
||||||
const { showConfTxPage } = require('../actions')
|
const { showConfTxPage } = require('../actions')
|
||||||
|
|
||||||
@ -53,16 +53,6 @@ TxList.prototype.render = function () {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
TxList.prototype.getAddressText = function (transaction) {
|
|
||||||
const {
|
|
||||||
txParams: { to },
|
|
||||||
} = transaction
|
|
||||||
|
|
||||||
return to
|
|
||||||
? `${to.slice(0, 10)}...${to.slice(-4)}`
|
|
||||||
: 'Contract Published'
|
|
||||||
}
|
|
||||||
|
|
||||||
TxList.prototype.renderTranstions = function () {
|
TxList.prototype.renderTranstions = function () {
|
||||||
const { txsToRender } = this.props
|
const { txsToRender } = this.props
|
||||||
|
|
||||||
@ -92,70 +82,21 @@ TxList.prototype.renderTransactionListItem = function (transaction) {
|
|||||||
} = props
|
} = props
|
||||||
const { showConfTxPage } = this.props
|
const { showConfTxPage } = this.props
|
||||||
|
|
||||||
return h('div.tx-list-item', {
|
if (!address) return null
|
||||||
key: transaction.id,
|
|
||||||
}, [
|
const opts = {
|
||||||
h('div.flex-column.tx-list-item__wrapper', {
|
transactionStatus,
|
||||||
onClick: () => transactionStatus === 'unapproved' && showConfTxPage({id: transActionId}),
|
transActionId,
|
||||||
style: {},
|
dateString,
|
||||||
}, [
|
address,
|
||||||
|
transactionAmount,
|
||||||
|
}
|
||||||
|
|
||||||
h('div.tx-list-date-wrapper', {
|
if (transactionStatus === 'unapproved') {
|
||||||
style: {},
|
opts.onClick = () => showConfTxPage({id: transActionId})
|
||||||
}, [
|
opts.className = '.tx-list-pending-item-container'
|
||||||
h('span.tx-list-date', {}, [
|
}
|
||||||
dateString,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('div.flex-row.tx-list-content-wrapper', {
|
return h(TxListItem, opts)
|
||||||
style: {},
|
|
||||||
}, [
|
|
||||||
|
|
||||||
h('div.tx-list-identicon-wrapper', {
|
|
||||||
style: {},
|
|
||||||
}, [
|
|
||||||
h(Identicon, {
|
|
||||||
address,
|
|
||||||
diameter: 28,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('div.tx-list-account-and-status-wrapper', {}, [
|
|
||||||
h('div.tx-list-account-wrapper', {
|
|
||||||
style: {},
|
|
||||||
}, [
|
|
||||||
h('span.tx-list-account', {}, [
|
|
||||||
this.getAddressText(transaction),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('div.tx-list-status-wrapper', {
|
|
||||||
style: {},
|
|
||||||
}, [
|
|
||||||
h('span.tx-list-status', {}, [
|
|
||||||
transactionStatus,
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('div.flex-column.tx-list-details-wrapper', {
|
|
||||||
style: {},
|
|
||||||
}, [
|
|
||||||
|
|
||||||
h('span.tx-list-value', {}, [
|
|
||||||
transactionAmount,
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('span.tx-list-fiat-value', {}, [
|
|
||||||
'+ $300 USD',
|
|
||||||
]),
|
|
||||||
|
|
||||||
]),
|
|
||||||
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,22 @@
|
|||||||
flex: 0 0 70px;
|
flex: 0 0 70px;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
|
||||||
|
@media screen and (max-width: $break-small) {
|
||||||
|
padding: 0 1.3em .95em;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: $break-large) {
|
||||||
|
margin: 0 2.37em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tx-list-pending-item-container {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tx-list-pending-item-container:hover {
|
||||||
|
background: $alto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tx-list-date-wrapper {
|
.tx-list-date-wrapper {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user