aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/accounts/account-list-item.js
blob: 4e0d69ed76400cf98c967996c7d9b9cbe00ec4f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const ethUtil = require('ethereumjs-util')

const EthBalance = require('../components/eth-balance')
const CopyButton = require('../components/copyButton')
const Identicon = require('../components/identicon')

module.exports = AccountListItem

inherits(AccountListItem, Component)
function AccountListItem () {
  Component.call(this)
}

AccountListItem.prototype.render = function () {
  const identity = this.props.identity
  var isSelected = this.props.selectedAddress === identity.address
  var account = this.props.accounts[identity.address]
  const selectedClass = isSelected ? '.selected' : ''

  return (
    h(`.accounts-list-option.flex-row.flex-space-between.pointer.hover-white${selectedClass}`, {
      key: `account-panel-${identity.address}`,
      onClick: (event) => this.props.onShowDetail(identity.address, event),
    }, [

      h('.identicon-wrapper.flex-column.flex-center.select-none', [
        this.pendingOrNot(),
        h(Identicon, {
          address: identity.address,
          imageify: true,
        }),
      ]),

      // account address, balance
      h('.identity-data.flex-column.flex-justify-center.flex-grow.select-none', {
        style: {
          width: '200px',
        },
      }, [
        h('span', identity.name),
        h('span.font-small', {
          style: {
            overflow: 'hidden',
            textOverflow: 'ellipsis',
          },
        }, ethUtil.toChecksumAddress(identity.address)),
        h(EthBalance, {
          value: account.balance,
          style: {
            lineHeight: '7px',
            marginTop: '10px',
          },
        }),
      ]),

      // copy button
      h('.identity-copy.flex-column', {
        style: {
          margin: '0 20px',
        },
      }, [
        h(CopyButton, {
          value: ethUtil.toChecksumAddress(identity.address),
        }),
      ]),
    ])
  )
}

AccountListItem.prototype.pendingOrNot = function () {
  const pending = this.props.pending
  if (pending.length === 0) return null
  return h('.pending-dot', pending.length)
}