mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-22 03:17:58 +00:00
refactor: rename polkadotIcon to pezkuwiIcon and update identicon themes
- Rename polkadot.ts to pezkuwi.ts in ui-shared - Rename polkadotIcon function to pezkuwiIcon - Rename Polkadot.tsx to Pezkuwi.tsx in all identicon packages - Update Components mapping to use pezkuwi theme - Add bizinikiwi theme as substrate replacement - Update IconTheme type definitions - Update Ledger app text to Pezkuwi
This commit is contained in:
@@ -11,7 +11,7 @@ import { ICON_DEFAULT_HOST, settings } from '@pezkuwi/ui-settings';
|
||||
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
||||
import { decodeAddress, encodeAddress, ethereumEncode } from '@pezkuwi/util-crypto';
|
||||
|
||||
import { Beachball, Empty, Ethereum, Jdenticon, Polkadot } from './icons/index.js';
|
||||
import { Beachball, Empty, Ethereum, Jdenticon, Pezkuwi } from './icons/index.js';
|
||||
import { styled } from './styled.js';
|
||||
|
||||
const Fallback = Beachball;
|
||||
@@ -24,11 +24,11 @@ interface State {
|
||||
const DEFAULT_SIZE = 64;
|
||||
const Components: Record<string, React.ComponentType<ComponentProps>> = {
|
||||
beachball: Beachball,
|
||||
bizinikiwi: Jdenticon,
|
||||
empty: Empty,
|
||||
ethereum: Ethereum,
|
||||
jdenticon: Jdenticon,
|
||||
polkadot: Polkadot,
|
||||
substrate: Jdenticon
|
||||
pezkuwi: Pezkuwi
|
||||
};
|
||||
|
||||
class BaseIcon extends React.PureComponent<Props, State> {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2018-2025 @pezkuwi/react-identicon authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Originally from: https://github.com/paritytech/oo7/tree/master/packages/polkadot-identicon
|
||||
// Copyright 2018 Paritytech - Adapted for PezkuwiChain ecosystem
|
||||
|
||||
import type { Circle } from '@pezkuwi/ui-shared/icons/types';
|
||||
import type { Props } from '../types.js';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { pezkuwiIcon } from '@pezkuwi/ui-shared';
|
||||
|
||||
function renderCircle ({ cx, cy, fill, r }: Circle, key: number): React.ReactNode {
|
||||
return (
|
||||
<circle
|
||||
cx={cx}
|
||||
cy={cy}
|
||||
fill={fill}
|
||||
key={key}
|
||||
r={r}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function Identicon ({ address, className = '', isAlternative = false, size, style = {} }: Props): React.ReactElement<Props> {
|
||||
const circles = useMemo(
|
||||
() => pezkuwiIcon(address, { isAlternative }),
|
||||
[address, isAlternative]
|
||||
);
|
||||
|
||||
return (
|
||||
<svg
|
||||
className={className}
|
||||
height={size}
|
||||
id={address}
|
||||
name={address}
|
||||
style={style}
|
||||
viewBox='0 0 64 64'
|
||||
width={size}
|
||||
>
|
||||
{circles.map(renderCircle)}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export const Pezkuwi = React.memo(Identicon);
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2018-2025 @pezkuwi/react-identicon authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
|
||||
|
||||
// This has been converted from the original version that can be found at
|
||||
//
|
||||
// https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
|
||||
//
|
||||
// Here we have done the following to convert the component -
|
||||
// - Converted the code to TypeScript
|
||||
// - Removed the oo7 dependencies (since not initialised properly, it makes calls to wrong endpoints)
|
||||
// - Remove encoding functionality, these are catered for in the base
|
||||
// - Remove copy functionality (this is catered from in the base components)
|
||||
// - Split calculations into relevant functions
|
||||
// - Move constants to file-level
|
||||
// - Overall it is now just a static component, expecting an address as an input value
|
||||
|
||||
import type { Circle } from '@pezkuwi/ui-shared/icons/types';
|
||||
import type { Props } from '../types.js';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { polkadotIcon } from '@pezkuwi/ui-shared';
|
||||
|
||||
function renderCircle ({ cx, cy, fill, r }: Circle, key: number): React.ReactNode {
|
||||
return (
|
||||
<circle
|
||||
cx={cx}
|
||||
cy={cy}
|
||||
fill={fill}
|
||||
key={key}
|
||||
r={r}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function Identicon ({ address, className = '', isAlternative = false, size, style = {} }: Props): React.ReactElement<Props> {
|
||||
const circles = useMemo(
|
||||
() => polkadotIcon(address, { isAlternative }),
|
||||
[address, isAlternative]
|
||||
);
|
||||
|
||||
return (
|
||||
<svg
|
||||
className={className}
|
||||
height={size}
|
||||
id={address}
|
||||
name={address}
|
||||
style={style}
|
||||
viewBox='0 0 64 64'
|
||||
width={size}
|
||||
>
|
||||
{circles.map(renderCircle)}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export const Polkadot = React.memo(Identicon);
|
||||
@@ -5,4 +5,4 @@ export { Beachball } from './Beachball.js';
|
||||
export { Empty } from './Empty.js';
|
||||
export { Ethereum } from './Ethereum.js';
|
||||
export { Jdenticon } from './Jdenticon.js';
|
||||
export { Polkadot } from './Polkadot.js';
|
||||
export { Pezkuwi } from './Pezkuwi.js';
|
||||
|
||||
@@ -27,4 +27,4 @@ export interface IdentityProps extends BaseProps {
|
||||
value?: string | Uint8Array | null;
|
||||
}
|
||||
|
||||
export type IconTheme = 'beachball' | 'empty' | 'ethereum' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||
export type IconTheme = 'beachball' | 'bizinikiwi' | 'empty' | 'ethereum' | 'jdenticon' | 'pezkuwi';
|
||||
|
||||
@@ -9,14 +9,14 @@ import React from 'react';
|
||||
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
||||
import { decodeAddress, encodeAddress } from '@pezkuwi/util-crypto';
|
||||
|
||||
import { Empty, Polkadot } from './icons/index.js';
|
||||
import { Empty, Pezkuwi } from './icons/index.js';
|
||||
|
||||
const Fallback = Polkadot;
|
||||
const Fallback = Pezkuwi;
|
||||
|
||||
interface Props {
|
||||
prefix?: Prefix;
|
||||
size?: number;
|
||||
theme?: 'polkadot';
|
||||
theme?: 'pezkuwi';
|
||||
value?: string | Uint8Array | null;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ interface State {
|
||||
}
|
||||
|
||||
const DEFAULT_SIZE = 64;
|
||||
const DEFAULT_THEME = 'polkadot';
|
||||
const DEFAULT_THEME = 'pezkuwi';
|
||||
|
||||
const Components: Record<string, React.ComponentType<ComponentProps>> = {
|
||||
polkadot: Polkadot
|
||||
pezkuwi: Pezkuwi
|
||||
};
|
||||
|
||||
export default class IdentityIcon extends React.PureComponent<Props, State> {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import React, { useMemo } from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { Circle as SvgCircle, Svg } from 'react-native-svg';
|
||||
|
||||
import { polkadotIcon } from '@pezkuwi/ui-shared';
|
||||
import { pezkuwiIcon } from '@pezkuwi/ui-shared';
|
||||
|
||||
function renderCircle ({ cx, cy, fill, r }: CircleType, key: number): React.ReactNode {
|
||||
return (
|
||||
@@ -24,7 +24,7 @@ function renderCircle ({ cx, cy, fill, r }: CircleType, key: number): React.Reac
|
||||
|
||||
export default function Identicon ({ address, isAlternative = false, size }: Props): React.ReactElement<Props> {
|
||||
const circles = useMemo(
|
||||
() => polkadotIcon(address, { isAlternative }),
|
||||
() => pezkuwiIcon(address, { isAlternative }),
|
||||
[address, isAlternative]
|
||||
);
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Empty } from './Empty.js';
|
||||
export { default as Polkadot } from './Polkadot.js';
|
||||
export { default as Pezkuwi } from './Pezkuwi.js';
|
||||
|
||||
@@ -34,7 +34,7 @@ export const LEDGER_APP_DEFAULT = 'generic';
|
||||
export const LEDGER_APP: Option[] = [
|
||||
{
|
||||
info: 'generic',
|
||||
text: 'Use the Ledger Polkadot Generic App',
|
||||
text: 'Use the Ledger Pezkuwi Generic App',
|
||||
value: 'generic'
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
// matches https://pezkuwichain.io & https://*.pezkuwichain.io
|
||||
export const isPezkuwi = typeof window !== 'undefined' && window.location.host.includes('pezkuwi');
|
||||
|
||||
// Backward compatibility alias
|
||||
// Alias for compatibility with code using old variable name
|
||||
export const isPolkadot = isPezkuwi;
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { beachballIcon } from './beachball/index.js';
|
||||
export { polkadotIcon } from './polkadot.js';
|
||||
export { pezkuwiIcon } from './pezkuwi.js';
|
||||
|
||||
+3
-3
@@ -3,12 +3,12 @@
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
import { polkadotIcon } from './polkadot.js';
|
||||
import { pezkuwiIcon } from './pezkuwi.js';
|
||||
|
||||
describe('polkadotIcon', (): void => {
|
||||
describe('pezkuwiIcon', (): void => {
|
||||
it('generates the correct points from known', (): void => {
|
||||
expect(
|
||||
polkadotIcon('5Dqvi1p4C7EhPPFKCixpF3QiaJEaDwWrR9gfWR5eUsfC39TX', { isAlternative: false })
|
||||
pezkuwiIcon('5Dqvi1p4C7EhPPFKCixpF3QiaJEaDwWrR9gfWR5eUsfC39TX', { isAlternative: false })
|
||||
).toEqual([
|
||||
{ cx: 32, cy: 32, fill: '#eee', r: 32 },
|
||||
{ cx: 32, cy: 8, fill: 'hsl(196, 65%, 53%)', r: 5 },
|
||||
@@ -1,11 +1,8 @@
|
||||
// Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
|
||||
|
||||
// This has been converted from the original version that can be found at
|
||||
//
|
||||
// https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
|
||||
// Originally from: https://github.com/paritytech/oo7/tree/master/packages/polkadot-identicon
|
||||
// Copyright 2018 Paritytech - Adapted for PezkuwiChain ecosystem
|
||||
|
||||
import type { Circle, Options } from './types.js';
|
||||
|
||||
@@ -134,7 +131,7 @@ function getColors (address: string): string[] {
|
||||
/**
|
||||
* @description Generates an array of the circles that make up an identicon
|
||||
*/
|
||||
export function polkadotIcon (address: string, { isAlternative }: Options): Circle[] {
|
||||
export function pezkuwiIcon (address: string, { isAlternative }: Options): Circle[] {
|
||||
const xy = getCircleXY(isAlternative);
|
||||
let colors: string[];
|
||||
|
||||
@@ -9,7 +9,7 @@ import { defineComponent, h } from 'vue';
|
||||
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
||||
import { decodeAddress, encodeAddress, isEthereumAddress } from '@pezkuwi/util-crypto';
|
||||
|
||||
import { Beachball, Empty, Jdenticon, Polkadot } from './icons/index.js';
|
||||
import { Beachball, Empty, Jdenticon, Pezkuwi } from './icons/index.js';
|
||||
import { adaptVNodeAttrs } from './util.js';
|
||||
|
||||
interface Account {
|
||||
@@ -22,7 +22,7 @@ interface Data {
|
||||
iconSize: number;
|
||||
isAlternativeIcon: boolean;
|
||||
publicKey: string;
|
||||
type: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||
type: 'beachball' | 'empty' | 'jdenticon' | 'pezkuwi' | 'bizinikiwi';
|
||||
}
|
||||
|
||||
const DEFAULT_SIZE = 64;
|
||||
@@ -53,7 +53,7 @@ export function encodeAccount (value: string | Uint8Array, prefix?: Prefix): Acc
|
||||
* @description The main Identicon component, taking a number of properties
|
||||
* @example
|
||||
* ```html
|
||||
* <Identicon :size="128" :theme="polkadot" :value="..." />
|
||||
* <Identicon :size="128" :theme="pezkuwi" :value="..." />
|
||||
* ```
|
||||
*/
|
||||
export const Identicon = defineComponent({
|
||||
@@ -61,7 +61,7 @@ export const Identicon = defineComponent({
|
||||
Beachball,
|
||||
Empty,
|
||||
Jdenticon,
|
||||
Polkadot
|
||||
Pezkuwi
|
||||
},
|
||||
created: function (): void {
|
||||
this.createData();
|
||||
@@ -110,16 +110,24 @@ export const Identicon = defineComponent({
|
||||
}
|
||||
)
|
||||
}, []);
|
||||
} else if (type === 'substrate') {
|
||||
throw new Error('substrate type is not supported');
|
||||
} else if (type === 'bizinikiwi') {
|
||||
return h(Jdenticon, {
|
||||
...adaptVNodeAttrs(
|
||||
{
|
||||
key: address,
|
||||
publicKey,
|
||||
size: iconSize
|
||||
}
|
||||
)
|
||||
}, []);
|
||||
}
|
||||
|
||||
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
||||
|
||||
if (['Beachball', 'Polkadot'].includes(cmp)) {
|
||||
if (['Beachball', 'Pezkuwi'].includes(cmp)) {
|
||||
const component = cmp === 'Beachball'
|
||||
? Beachball
|
||||
: Polkadot;
|
||||
: Pezkuwi;
|
||||
|
||||
return h(component, {
|
||||
...adaptVNodeAttrs({
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ import type { VNode } from 'vue';
|
||||
|
||||
import { defineComponent, h } from 'vue';
|
||||
|
||||
import { polkadotIcon } from '@pezkuwi/ui-shared';
|
||||
import { pezkuwiIcon } from '@pezkuwi/ui-shared';
|
||||
|
||||
import { adaptVNodeAttrs } from '../util.js';
|
||||
|
||||
@@ -16,14 +16,14 @@ interface propsType {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Polkadot
|
||||
* @description The Polkadot default identicon
|
||||
* @name Pezkuwi
|
||||
* @description The Pezkuwi default identicon
|
||||
*/
|
||||
export const Polkadot = defineComponent({
|
||||
export const Pezkuwi = defineComponent({
|
||||
props: ['address', 'isAlternative', 'size'],
|
||||
render (): VNode {
|
||||
const { address, isAlternative, size } = this.$props as propsType;
|
||||
const circles = polkadotIcon(address, { isAlternative }).map(({ cx, cy, fill, r }) =>
|
||||
const circles = pezkuwiIcon(address, { isAlternative }).map(({ cx, cy, fill, r }) =>
|
||||
h('circle', { ...adaptVNodeAttrs({ cx, cy, fill, r }) }, [])
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2025 @pezkuwi/reactnative-identicon authors & contributors
|
||||
// Copyright 2017-2025 @pezkuwi/vue-identicon authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './Beachball.js';
|
||||
export * from './Empty.js';
|
||||
export * from './Jdenticon.js';
|
||||
export * from './Polkadot.js';
|
||||
export * from './Pezkuwi.js';
|
||||
|
||||
Reference in New Issue
Block a user