ghost-portal/packages/ui-identicon
2018-11-26 09:12:00 +00:00
..
src Add TSLint (#106) 2018-06-27 12:43:07 +02:00
demo.png Include ui-* packages in repo (development speed) (#65) 2018-05-29 17:33:29 +02:00
index.html Include ui-* packages in repo (development speed) (#65) 2018-05-29 17:33:29 +02:00
LICENSE Copyright project authors (#95) 2018-06-13 22:32:49 +02:00
package.json [CI Skip] 0.20.30 2018-11-26 09:12:00 +00:00
README.md Include ui-* packages in repo (development speed) (#65) 2018-05-29 17:33:29 +02:00
webpack.config.js Support enumerable accounts (#102) 2018-06-25 18:02:47 +02:00

polkadotjs isc style npm travis maintainability coverage dependency devDependency

@polkadot/ui-identicon

Adapted from Jazzicon by Dan Finlay with the following changes -

  • Random values now is read from the Uint8Array supplied (as opposed to having the seed as a number). This allows us to give an publicKey/address as an input and use those values in the pattern generation.
  • Upgrade to the underlying color library
  • Generate circles as shapes (instead of rectangles)
  • Interface updated to take in optional className & style
  • Update everywhere to use ES6
  • Split source into self-contained functions (TODO: future testing)
  • Everything has been updated to use flow
  • Test the library functions
  • Copyright headers added (original also under ISC)

Usage

import identicon from '@polkadot/ui-identicon';

const publicKey = new Uint8Array([...]); // 32 bytes
const body = document.querySelector('body');
const identity = identicon(publicKey, 100 /* diameter, optional */, 'my-class' /* className, optional */ /* style. optional */ /* colors, optional */);

body.append(identity);

Also see src/demo.js for a randomly generated example.

demo