isAlternative (#308)

This commit is contained in:
Jaco Greeff
2020-04-12 07:28:16 +02:00
committed by GitHub
parent 87187649d1
commit a268160ffd
22 changed files with 618 additions and 472 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import generate from './polkadotIcon';
describe('polkadotIcon', (): void => {
it('generates the correct points from known', (): void => {
expect(
generate('5Dqvi1p4C7EhPPFKCixpF3QiaJEaDwWrR9gfWR5eUsfC39TX')
generate('5Dqvi1p4C7EhPPFKCixpF3QiaJEaDwWrR9gfWR5eUsfC39TX', { isSixPoint: false })
).toEqual([
{ cx: 32, cy: 32, fill: '#eee', r: 32 },
{ cx: 32, cy: 8, fill: 'hsl(196, 65%, 53%)', r: 5 },
+6 -7
View File
@@ -7,13 +7,12 @@
//
// https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
import { Circle } from './types';
import { blake2AsU8a, decodeAddress } from '@polkadot/util-crypto';
export interface Circle {
cx: number;
cy: number;
fill: string;
r: number;
interface Options {
isSixPoint: boolean;
}
interface Scheme {
@@ -134,9 +133,9 @@ function getColors (address: string): string[] {
}
/**
* @description Generate a array of the circles that make up an indenticon
* @description Generate a array of the circles that make up an identicon
*/
export default function generate (address: string, isSixPoint = false): Circle[] {
export default function generate (address: string, { isSixPoint }: Options): Circle[] {
const colors = getColors(address);
return [OUTER_CIRCLE].concat(
+10
View File
@@ -0,0 +1,10 @@
// Copyright 2018 @polkadot/ui-shared authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export interface Circle {
cx: number;
cy: number;
fill: string;
r: number;
}