blob: 8294ce4d582f9a9ce58fe8f752d51f872a259626 (
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
|
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const jazzicon = require('jazzicon')
const findDOMNode = require('react-dom').findDOMNode
module.exports = IdenticonComponent
inherits(IdenticonComponent, Component)
function IdenticonComponent() {
Component.call(this)
this.diameter = 46
}
IdenticonComponent.prototype.render = function() {
debugger
return (
h('div', {
key: 'identicon-' + this.props.address,
style: {
display: 'inline-block',
height: this.diameter,
width: this.diameter,
borderRadius: this.diameter / 2,
overflow: 'hidden',
},
})
)
}
IdenticonComponent.prototype.componentDidMount = function(){
var state = this.props
var address = state.address
if (!address) return
console.log('rendering for address ' + address)
var numericRepresentation = jsNumberForAddress(address)
var container = findDOMNode(this)
var identicon = jazzicon(this.diameter, numericRepresentation)
container.appendChild(identicon)
}
function jsNumberForAddress(address) {
var addr = address.slice(2, 10)
var seed = parseInt(addr, 16)
return seed
}
|