aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/blockies/blockies-component.js
blob: d6defda1604b1a79c896bc11624f668d9321fbe9 (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
const Component = require('react').Component
const createElement  = require('react').createElement
const blockies = require("ethereum-blockies");

class BlockiesIdenticon extends Component {
  constructor(props) {
    super(props);
  }
  getOpts () {
    return {
      seed: this.props.seed || "foo",
      color: this.props.color || "#dfe",
      bgcolor: this.props.bgcolor || "#a71",
      size: this.props.size || 15,
      scale: this.props.scale || 3,
      spotcolor: this.props.spotcolor || "#000"
    };
  }
  componentDidMount() {
    this.draw();
  }
  draw() {
    blockies.render(this.getOpts(), this.canvas);
  }
  render() {
    return createElement("canvas", {ref: canvas => this.canvas = canvas});
  }
}

module.exports = BlockiesIdenticon;