mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 02:51:03 +00:00
Add documentation on GH pages (#85)
* Add documentation on GH pages * Expand classes for doc generation * Update docs * .nojekyll * Update Identicon.tsx * Update Demo.tsx * Update KeyPair.tsx * Export specific icons * Convert tests to TypeScript
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
A generic identity icon that can render icons based on the theme, be it Substrate or Polkadot
|
||||
|
||||
## Usage
|
||||
## Usage Examples
|
||||
|
||||
To install the component, do `yarn add @polkadot/ui-identicon`
|
||||
|
||||
@@ -17,7 +17,8 @@ render () {
|
||||
const { address } = this.props;
|
||||
// size (optional) is a number, indicating the size (in pixels, 64 as default)
|
||||
const size = 32;
|
||||
// theme (optional), depicts the type of icon, either 'polkadot' or 'substrate' (default)
|
||||
// theme (optional), depicts the type of icon, one of
|
||||
// 'polkadot', 'substrate' (default), 'beachball' or 'jdenticon'
|
||||
const theme = 'polkadot';
|
||||
|
||||
// standard className & style props are also available
|
||||
|
||||
+3
-1
@@ -2,11 +2,13 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ColorGen } from './types';
|
||||
|
||||
import newSeeder from './seeder';
|
||||
import newColors from './colors';
|
||||
|
||||
describe('colors', () => {
|
||||
let colors;
|
||||
let colors: ColorGen;
|
||||
|
||||
beforeEach(() => {
|
||||
colors = newColors(newSeeder());
|
||||
@@ -3,16 +3,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Seeder } from './types';
|
||||
import { ColorGen, Seeder } from './types';
|
||||
|
||||
import Color from 'color';
|
||||
|
||||
import { COLORS } from './defaults';
|
||||
|
||||
type ColorGen = {
|
||||
(alpha?: number): string
|
||||
};
|
||||
|
||||
const WOBBLE = 30;
|
||||
|
||||
export default function colors (seeder: Seeder): ColorGen {
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import container from './container';
|
||||
describe('container', () => {
|
||||
it('applies default styles', () => {
|
||||
expect(
|
||||
container(100).style._values
|
||||
(container(100).style as any)._values
|
||||
).toMatchObject({
|
||||
'background': 'white',
|
||||
'border-radius': '50px',
|
||||
@@ -22,7 +22,7 @@ describe('container', () => {
|
||||
|
||||
it('overrides with supplied styles', () => {
|
||||
expect(
|
||||
container(50, 'black', '', { display: 'block' }).style._values
|
||||
(container(50, 'black', '', { display: 'block' }).style as any)._values
|
||||
).toMatchObject({
|
||||
'background': 'black',
|
||||
'border-radius': '25px',
|
||||
@@ -10,7 +10,7 @@ import newShape from './shape/circle';
|
||||
import newElement from './svg/element';
|
||||
import { SHAPE_COUNT } from './defaults';
|
||||
|
||||
export default function identicon (seed: string, diameter: number = 256, className: string = '', style?: { [index: string]: string }): HTMLElement {
|
||||
export default function identicon (seed: string | Uint8Array, diameter: number = 256, className: string = '', style?: { [index: string]: string }): HTMLElement {
|
||||
const seeder = newSeeder(seed);
|
||||
const colorGen = colors(seeder);
|
||||
const outer = newContainer(diameter, 'white', className, style);
|
||||
|
||||
+3
-1
@@ -2,10 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Seeder } from './types';
|
||||
|
||||
import newSeeder from './seeder';
|
||||
|
||||
describe('seeder', () => {
|
||||
let seeder;
|
||||
let seeder: Seeder;
|
||||
|
||||
beforeEach(() => {
|
||||
seeder = newSeeder(new Uint8Array([1, 2, 3, 4]));
|
||||
@@ -3,3 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export type Seeder = () => number;
|
||||
|
||||
export type ColorGen = {
|
||||
(alpha?: number): string
|
||||
};
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
declare module 'xmlserializer';
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { default as Identicon } from './Identicon';
|
||||
export * from './icons';
|
||||
|
||||
export default Identicon;
|
||||
Reference in New Issue
Block a user