mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-21 06:21:03 +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';
|
||||
|
||||
Reference in New Issue
Block a user