@pezkuwi/react-identicon 3.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +34 -0
  2. package/build/Identicon.d.ts +5 -0
  3. package/build/Identicon.js +104 -0
  4. package/build/LICENSE +201 -0
  5. package/build/README.md +34 -0
  6. package/build/bundle-pezkuwi-react-identicon.js +2858 -0
  7. package/build/bundle.d.ts +3 -0
  8. package/build/bundle.js +3 -0
  9. package/build/cjs/Identicon.d.ts +5 -0
  10. package/build/cjs/Identicon.js +108 -0
  11. package/build/cjs/bundle.d.ts +3 -0
  12. package/build/cjs/bundle.js +9 -0
  13. package/build/cjs/icons/Beachball.d.ts +5 -0
  14. package/build/cjs/icons/Beachball.js +17 -0
  15. package/build/cjs/icons/Empty.d.ts +5 -0
  16. package/build/cjs/icons/Empty.js +10 -0
  17. package/build/cjs/icons/Ethereum.d.ts +5 -0
  18. package/build/cjs/icons/Ethereum.js +18 -0
  19. package/build/cjs/icons/Jdenticon.d.ts +5 -0
  20. package/build/cjs/icons/Jdenticon.js +12 -0
  21. package/build/cjs/icons/Polkadot.d.ts +5 -0
  22. package/build/cjs/icons/Polkadot.js +15 -0
  23. package/build/cjs/icons/index.d.ts +5 -0
  24. package/build/cjs/icons/index.js +13 -0
  25. package/build/cjs/index.d.ts +4 -0
  26. package/build/cjs/index.js +7 -0
  27. package/build/cjs/package.json +3 -0
  28. package/build/cjs/packageDetect.d.ts +1 -0
  29. package/build/cjs/packageDetect.js +7 -0
  30. package/build/cjs/packageInfo.d.ts +6 -0
  31. package/build/cjs/packageInfo.js +4 -0
  32. package/build/cjs/styled.d.ts +1 -0
  33. package/build/cjs/styled.js +5 -0
  34. package/build/cjs/types.d.ts +23 -0
  35. package/build/cjs/types.js +2 -0
  36. package/build/icons/Beachball.d.ts +5 -0
  37. package/build/icons/Beachball.js +13 -0
  38. package/build/icons/Empty.d.ts +5 -0
  39. package/build/icons/Empty.js +6 -0
  40. package/build/icons/Ethereum.d.ts +5 -0
  41. package/build/icons/Ethereum.js +14 -0
  42. package/build/icons/Jdenticon.d.ts +5 -0
  43. package/build/icons/Jdenticon.js +8 -0
  44. package/build/icons/Polkadot.d.ts +5 -0
  45. package/build/icons/Polkadot.js +11 -0
  46. package/build/icons/index.d.ts +5 -0
  47. package/build/icons/index.js +5 -0
  48. package/build/index.d.ts +4 -0
  49. package/build/index.js +4 -0
  50. package/build/package.json +249 -0
  51. package/build/packageDetect.d.ts +1 -0
  52. package/build/packageDetect.js +5 -0
  53. package/build/packageInfo.d.ts +6 -0
  54. package/build/packageInfo.js +1 -0
  55. package/build/styled.d.ts +1 -0
  56. package/build/styled.js +1 -0
  57. package/build/types.d.ts +23 -0
  58. package/build/types.js +1 -0
  59. package/build-tsc/Identicon.d.ts +5 -0
  60. package/build-tsc/bundle.d.ts +3 -0
  61. package/build-tsc/icons/Beachball.d.ts +5 -0
  62. package/build-tsc/icons/Empty.d.ts +5 -0
  63. package/build-tsc/icons/Ethereum.d.ts +5 -0
  64. package/build-tsc/icons/Jdenticon.d.ts +5 -0
  65. package/build-tsc/icons/Polkadot.d.ts +5 -0
  66. package/build-tsc/icons/index.d.ts +5 -0
  67. package/build-tsc/index.d.ts +4 -0
  68. package/build-tsc/packageDetect.d.ts +1 -0
  69. package/build-tsc/packageInfo.d.ts +6 -0
  70. package/build-tsc/styled.d.ts +1 -0
  71. package/build-tsc/types.d.ts +23 -0
  72. package/build-tsc-cjs/Identicon.js +108 -0
  73. package/build-tsc-cjs/bundle.js +9 -0
  74. package/build-tsc-cjs/icons/Beachball.js +17 -0
  75. package/build-tsc-cjs/icons/Empty.js +10 -0
  76. package/build-tsc-cjs/icons/Ethereum.js +18 -0
  77. package/build-tsc-cjs/icons/Jdenticon.js +12 -0
  78. package/build-tsc-cjs/icons/Polkadot.js +15 -0
  79. package/build-tsc-cjs/icons/index.js +13 -0
  80. package/build-tsc-cjs/index.js +7 -0
  81. package/build-tsc-cjs/packageDetect.js +7 -0
  82. package/build-tsc-cjs/packageInfo.js +4 -0
  83. package/build-tsc-cjs/styled.js +5 -0
  84. package/build-tsc-cjs/types.js +2 -0
  85. package/build-tsc-esm/Identicon.js +104 -0
  86. package/build-tsc-esm/bundle.js +3 -0
  87. package/build-tsc-esm/icons/Beachball.js +13 -0
  88. package/build-tsc-esm/icons/Empty.js +6 -0
  89. package/build-tsc-esm/icons/Ethereum.js +14 -0
  90. package/build-tsc-esm/icons/Jdenticon.js +8 -0
  91. package/build-tsc-esm/icons/Polkadot.js +11 -0
  92. package/build-tsc-esm/icons/index.js +5 -0
  93. package/build-tsc-esm/index.js +4 -0
  94. package/build-tsc-esm/packageDetect.js +5 -0
  95. package/build-tsc-esm/packageInfo.js +1 -0
  96. package/build-tsc-esm/styled.js +1 -0
  97. package/build-tsc-esm/types.js +1 -0
  98. package/demo.png +0 -0
  99. package/index.html +17 -0
  100. package/package.json +48 -0
  101. package/src/Identicon.tsx +154 -0
  102. package/src/bundle.ts +6 -0
  103. package/src/icons/Beachball.tsx +32 -0
  104. package/src/icons/Empty.tsx +20 -0
  105. package/src/icons/Ethereum.tsx +37 -0
  106. package/src/icons/Jdenticon.tsx +24 -0
  107. package/src/icons/Polkadot.tsx +59 -0
  108. package/src/icons/index.ts +8 -0
  109. package/src/index.ts +10 -0
  110. package/src/packageDetect.ts +13 -0
  111. package/src/packageInfo.ts +6 -0
  112. package/src/styled.ts +4 -0
  113. package/src/types.ts +30 -0
  114. package/tsconfig.build.json +12 -0
  115. package/tsconfig.build.tsbuildinfo +1 -0
@@ -0,0 +1,104 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import CopyToClipboard from 'react-copy-to-clipboard';
4
+ import { ICON_DEFAULT_HOST, settings } from '@pezkuwi/ui-settings';
5
+ import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
6
+ import { decodeAddress, encodeAddress, ethereumEncode } from '@pezkuwi/util-crypto';
7
+ import { Beachball, Empty, Ethereum, Jdenticon, Polkadot } from './icons/index.js';
8
+ import { styled } from './styled.js';
9
+ const Fallback = Beachball;
10
+ const DEFAULT_SIZE = 64;
11
+ const Components = {
12
+ beachball: Beachball,
13
+ empty: Empty,
14
+ ethereum: Ethereum,
15
+ jdenticon: Jdenticon,
16
+ polkadot: Polkadot,
17
+ substrate: Jdenticon
18
+ };
19
+ class BaseIcon extends React.PureComponent {
20
+ state = {
21
+ address: '',
22
+ publicKey: '0x'
23
+ };
24
+ static prefix = undefined;
25
+ static setDefaultPrefix(prefix) {
26
+ BaseIcon.prefix = prefix;
27
+ }
28
+ static getDerivedStateFromProps({ prefix = BaseIcon.prefix, theme, value }, prevState) {
29
+ if (theme === 'ethereum') {
30
+ const address = isU8a(value)
31
+ ? ethereumEncode(value)
32
+ : value || '';
33
+ return { address, publicKey: '' };
34
+ }
35
+ try {
36
+ const address = isU8a(value) || isHex(value)
37
+ ? encodeAddress(value, prefix)
38
+ : (value || '');
39
+ const publicKey = u8aToHex(decodeAddress(address, false, prefix));
40
+ return address === prevState.address
41
+ ? null
42
+ : {
43
+ address,
44
+ publicKey
45
+ };
46
+ }
47
+ catch {
48
+ return {
49
+ address: '',
50
+ publicKey: '0x'
51
+ };
52
+ }
53
+ }
54
+ render() {
55
+ const { address } = this.state;
56
+ const wrapped = this.getWrapped(this.state, this.props);
57
+ return !address
58
+ ? wrapped
59
+ : (_jsx(CopyToClipboard, { onCopy: this.onCopy, text: address, children: wrapped }));
60
+ }
61
+ getWrapped({ address, publicKey }, { Custom }) {
62
+ const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style = {}, theme = settings.icon } = this.props;
63
+ const Component = !address
64
+ ? Empty
65
+ : Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
66
+ return (_jsx(StyledDiv, { className: `ui--IdentityIcon ${className}`, style: style, children: _jsx(Component, { address: address, className: isHighlight ? 'highlight' : '', isAlternative: isAlternative, publicKey: publicKey, size: size }) }, address));
67
+ }
68
+ onCopy = () => {
69
+ const { onCopy } = this.props;
70
+ const { address } = this.state;
71
+ if (address && onCopy) {
72
+ onCopy(address);
73
+ }
74
+ };
75
+ }
76
+ function Icon(props) {
77
+ return _jsx(BaseIcon, { ...props });
78
+ }
79
+ const StyledDiv = styled.div `
80
+ cursor: copy;
81
+ display: inline-block;
82
+ line-height: 0;
83
+
84
+ > .container {
85
+ position: relative;
86
+
87
+ > div,
88
+ > svg {
89
+ position: relative;
90
+ }
91
+
92
+ &.highlight:before {
93
+ position: absolute;
94
+ top: 0;
95
+ left: 0;
96
+ right: 0;
97
+ bottom: 0;
98
+ border-radius: 50%;
99
+ box-shadow: 0 0 5px 2px #aaa;
100
+ content: '';
101
+ }
102
+ }
103
+ `;
104
+ export const Identicon = React.memo(Icon);
@@ -0,0 +1,3 @@
1
+ export * from './icons/index.js';
2
+ export { Identicon } from './Identicon.js';
3
+ export { packageInfo } from './packageInfo.js';
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useCallback } from 'react';
3
+ import { beachballIcon } from '@pezkuwi/ui-shared';
4
+ function Identicon({ address, className = '', size, style = {} }) {
5
+ const updateElem = useCallback((node) => {
6
+ if (node) {
7
+ node.innerHTML = '';
8
+ node.appendChild(beachballIcon(address, { isAlternative: false, size }));
9
+ }
10
+ }, [address, size]);
11
+ return (_jsx("div", { className: className, ref: updateElem, style: style }));
12
+ }
13
+ export const Beachball = React.memo(Identicon);
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ function Identicon({ className = '', size, style = {} }) {
4
+ return (_jsx("svg", { className: className, height: size, style: style, viewBox: '0 0 64 64', width: size }));
5
+ }
6
+ export const Empty = React.memo(Identicon);
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import makeBlockie from 'ethereum-blockies-base64';
3
+ import React, { useMemo } from 'react';
4
+ import { styled } from '../styled.js';
5
+ function Identicon({ address, className = '', size, style = {} }) {
6
+ const imgSrc = useMemo(() => makeBlockie(address), [address]);
7
+ return (_jsx(StyledImg, { className: className, size: size, src: imgSrc, style: style }));
8
+ }
9
+ const StyledImg = styled.img(({ size }) => `
10
+ display: block;
11
+ height: ${size}px;
12
+ width: ${size}px;
13
+ `);
14
+ export const Ethereum = React.memo(Identicon);
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as jdenticon from 'jdenticon';
3
+ import React, { useMemo } from 'react';
4
+ function Identicon({ className = '', publicKey, size, style = {} }) {
5
+ const html = useMemo(() => ({ __html: jdenticon.toSvg(publicKey.substring(2), size) }), [publicKey, size]);
6
+ return (_jsx("div", { className: className, dangerouslySetInnerHTML: html, style: style }));
7
+ }
8
+ export const Jdenticon = React.memo(Identicon);
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useMemo } from 'react';
3
+ import { polkadotIcon } from '@pezkuwi/ui-shared';
4
+ function renderCircle({ cx, cy, fill, r }, key) {
5
+ return (_jsx("circle", { cx: cx, cy: cy, fill: fill, r: r }, key));
6
+ }
7
+ function Identicon({ address, className = '', isAlternative = false, size, style = {} }) {
8
+ const circles = useMemo(() => polkadotIcon(address, { isAlternative }), [address, isAlternative]);
9
+ return (_jsx("svg", { className: className, height: size, id: address, name: address, style: style, viewBox: '0 0 64 64', width: size, children: circles.map(renderCircle) }));
10
+ }
11
+ export const Polkadot = React.memo(Identicon);
@@ -0,0 +1,5 @@
1
+ export { Beachball } from './Beachball.js';
2
+ export { Empty } from './Empty.js';
3
+ export { Ethereum } from './Ethereum.js';
4
+ export { Jdenticon } from './Jdenticon.js';
5
+ export { Polkadot } from './Polkadot.js';
@@ -0,0 +1,4 @@
1
+ import './packageDetect.js';
2
+ import { Identicon } from './bundle.js';
3
+ export * from './bundle.js';
4
+ export default Identicon;
@@ -0,0 +1,5 @@
1
+ import { packageInfo as settingsInfo } from '@pezkuwi/ui-settings/packageInfo';
2
+ import { packageInfo as sharedInfo } from '@pezkuwi/ui-shared/packageInfo';
3
+ import { detectPackage } from '@pezkuwi/util';
4
+ import { packageInfo } from './packageInfo.js';
5
+ detectPackage(packageInfo, null, [settingsInfo, sharedInfo]);
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/react-identicon', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.16.6' };
@@ -0,0 +1 @@
1
+ export { styled } from 'styled-components';
@@ -0,0 +1 @@
1
+ export {};
package/demo.png ADDED
Binary file
package/index.html ADDED
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
4
+ <style>
5
+ #demo {
6
+ padding: 0.5em;
7
+ }
8
+ .padded {
9
+ margin: 0.5em !important;
10
+ }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <div id="demo"></div>
15
+ <script src="./build/Demo.js"></script>
16
+ </body>
17
+ </html>
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/ui/issues",
4
+ "description": "Renders an SVG picture representing an address",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/ui/tree/master/packages/react-identicon#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/react-identicon",
11
+ "repository": {
12
+ "directory": "packages/react-identicon",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/ui.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./packageDetect.cjs"
19
+ ],
20
+ "type": "module",
21
+ "version": "3.16.6",
22
+ "main": "index.js",
23
+ "dependencies": {
24
+ "@pezkuwi/keyring": "^14.0.5",
25
+ "@pezkuwi/ui-settings": "3.16.6",
26
+ "@pezkuwi/ui-shared": "3.16.6",
27
+ "@pezkuwi/util": "^14.0.5",
28
+ "@pezkuwi/util-crypto": "^14.0.5",
29
+ "ethereum-blockies-base64": "^1.0.2",
30
+ "jdenticon": "3.2.0",
31
+ "react-copy-to-clipboard": "^5.1.0",
32
+ "styled-components": "^6.1.1",
33
+ "tslib": "^2.8.1"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react-copy-to-clipboard": "^5.0.7",
37
+ "@types/react-dom": "^18.2.18",
38
+ "xmlserializer": "^0.6.1"
39
+ },
40
+ "peerDependencies": {
41
+ "@pezkuwi/keyring": "*",
42
+ "@pezkuwi/util": "*",
43
+ "@pezkuwi/util-crypto": "*",
44
+ "react": "*",
45
+ "react-dom": "*",
46
+ "react-is": "*"
47
+ }
48
+ }
@@ -0,0 +1,154 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Prefix } from '@pezkuwi/util-crypto/address/types';
5
+ import type { IdentityProps as Props, Props as ComponentProps } from './types.js';
6
+
7
+ import React from 'react';
8
+ import CopyToClipboard from 'react-copy-to-clipboard';
9
+
10
+ import { ICON_DEFAULT_HOST, settings } from '@pezkuwi/ui-settings';
11
+ import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
12
+ import { decodeAddress, encodeAddress, ethereumEncode } from '@pezkuwi/util-crypto';
13
+
14
+ import { Beachball, Empty, Ethereum, Jdenticon, Polkadot } from './icons/index.js';
15
+ import { styled } from './styled.js';
16
+
17
+ const Fallback = Beachball;
18
+
19
+ interface State {
20
+ address: string;
21
+ publicKey: string;
22
+ }
23
+
24
+ const DEFAULT_SIZE = 64;
25
+ const Components: Record<string, React.ComponentType<ComponentProps>> = {
26
+ beachball: Beachball,
27
+ empty: Empty,
28
+ ethereum: Ethereum,
29
+ jdenticon: Jdenticon,
30
+ polkadot: Polkadot,
31
+ substrate: Jdenticon
32
+ };
33
+
34
+ class BaseIcon extends React.PureComponent<Props, State> {
35
+ public override state: State = {
36
+ address: '',
37
+ publicKey: '0x'
38
+ };
39
+
40
+ private static prefix?: Prefix = undefined;
41
+
42
+ public static setDefaultPrefix (prefix: Prefix): void {
43
+ BaseIcon.prefix = prefix;
44
+ }
45
+
46
+ public static getDerivedStateFromProps ({ prefix = BaseIcon.prefix, theme, value }: Props, prevState: State): State | null {
47
+ if (theme === 'ethereum') {
48
+ const address = isU8a(value)
49
+ ? ethereumEncode(value)
50
+ : value || '';
51
+
52
+ return { address, publicKey: '' };
53
+ }
54
+
55
+ try {
56
+ const address = isU8a(value) || isHex(value)
57
+ ? encodeAddress(value, prefix)
58
+ : (value || '');
59
+ const publicKey = u8aToHex(decodeAddress(address, false, prefix));
60
+
61
+ return address === prevState.address
62
+ ? null
63
+ : {
64
+ address,
65
+ publicKey
66
+ };
67
+ } catch {
68
+ return {
69
+ address: '',
70
+ publicKey: '0x'
71
+ };
72
+ }
73
+ }
74
+
75
+ public override render (): React.ReactNode {
76
+ const { address } = this.state;
77
+ const wrapped = this.getWrapped(this.state, this.props);
78
+
79
+ return !address
80
+ ? wrapped
81
+ : (
82
+ <CopyToClipboard
83
+ onCopy={this.onCopy}
84
+ text={address}
85
+ >
86
+ {wrapped}
87
+ </CopyToClipboard>
88
+ );
89
+ }
90
+
91
+ private getWrapped ({ address, publicKey }: State, { Custom }: Props): React.ReactNode {
92
+ const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style = {}, theme = settings.icon } = this.props;
93
+ const Component = !address
94
+ ? Empty
95
+ : Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
96
+
97
+ return (
98
+ <StyledDiv
99
+ className={`ui--IdentityIcon ${className}`}
100
+ key={address}
101
+ style={style}
102
+ >
103
+ <Component
104
+ address={address}
105
+ className={isHighlight ? 'highlight' : ''}
106
+ isAlternative={isAlternative}
107
+ publicKey={publicKey}
108
+ size={size}
109
+ />
110
+ </StyledDiv>
111
+ );
112
+ }
113
+
114
+ private onCopy = (): void => {
115
+ const { onCopy } = this.props;
116
+ const { address } = this.state;
117
+
118
+ if (address && onCopy) {
119
+ onCopy(address);
120
+ }
121
+ };
122
+ }
123
+
124
+ function Icon (props: Props): React.ReactElement<Props> {
125
+ return <BaseIcon {...props} />;
126
+ }
127
+
128
+ const StyledDiv = styled.div`
129
+ cursor: copy;
130
+ display: inline-block;
131
+ line-height: 0;
132
+
133
+ > .container {
134
+ position: relative;
135
+
136
+ > div,
137
+ > svg {
138
+ position: relative;
139
+ }
140
+
141
+ &.highlight:before {
142
+ position: absolute;
143
+ top: 0;
144
+ left: 0;
145
+ right: 0;
146
+ bottom: 0;
147
+ border-radius: 50%;
148
+ box-shadow: 0 0 5px 2px #aaa;
149
+ content: '';
150
+ }
151
+ }
152
+ `;
153
+
154
+ export const Identicon = React.memo(Icon);
package/src/bundle.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './icons/index.js';
5
+ export { Identicon } from './Identicon.js';
6
+ export { packageInfo } from './packageInfo.js';
@@ -0,0 +1,32 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Props } from '../types.js';
5
+
6
+ import React, { useCallback } from 'react';
7
+
8
+ import { beachballIcon } from '@pezkuwi/ui-shared';
9
+
10
+ function Identicon ({ address, className = '', size, style = {} }: Props): React.ReactElement<Props> {
11
+ const updateElem = useCallback(
12
+ (node: HTMLDivElement): void => {
13
+ if (node) {
14
+ node.innerHTML = '';
15
+ node.appendChild(
16
+ beachballIcon(address, { isAlternative: false, size })
17
+ );
18
+ }
19
+ },
20
+ [address, size]
21
+ );
22
+
23
+ return (
24
+ <div
25
+ className={className}
26
+ ref={updateElem}
27
+ style={style}
28
+ />
29
+ );
30
+ }
31
+
32
+ export const Beachball = React.memo(Identicon);
@@ -0,0 +1,20 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Props } from '../types.js';
5
+
6
+ import React from 'react';
7
+
8
+ function Identicon ({ className = '', size, style = {} }: Props): React.ReactElement<Props> {
9
+ return (
10
+ <svg
11
+ className={className}
12
+ height={size}
13
+ style={style}
14
+ viewBox='0 0 64 64'
15
+ width={size}
16
+ />
17
+ );
18
+ }
19
+
20
+ export const Empty = React.memo(Identicon);
@@ -0,0 +1,37 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Props } from '../types.js';
5
+
6
+ import makeBlockie from 'ethereum-blockies-base64';
7
+ import React, { useMemo } from 'react';
8
+
9
+ import { styled } from '../styled.js';
10
+
11
+ interface ImgProps {
12
+ size: number;
13
+ }
14
+
15
+ function Identicon ({ address, className = '', size, style = {} }: Props): React.ReactElement<Props> {
16
+ const imgSrc = useMemo(
17
+ () => makeBlockie(address),
18
+ [address]
19
+ );
20
+
21
+ return (
22
+ <StyledImg
23
+ className={className}
24
+ size={size}
25
+ src={imgSrc}
26
+ style={style}
27
+ />
28
+ );
29
+ }
30
+
31
+ const StyledImg = styled.img<ImgProps>(({ size }) => `
32
+ display: block;
33
+ height: ${size}px;
34
+ width: ${size}px;
35
+ `);
36
+
37
+ export const Ethereum = React.memo(Identicon);
@@ -0,0 +1,24 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Props } from '../types.js';
5
+
6
+ import * as jdenticon from 'jdenticon';
7
+ import React, { useMemo } from 'react';
8
+
9
+ function Identicon ({ className = '', publicKey, size, style = {} }: Props): React.ReactElement<Props> {
10
+ const html = useMemo(
11
+ () => ({ __html: jdenticon.toSvg(publicKey.substring(2), size) }),
12
+ [publicKey, size]
13
+ );
14
+
15
+ return (
16
+ <div
17
+ className={className}
18
+ dangerouslySetInnerHTML={html}
19
+ style={style}
20
+ />
21
+ );
22
+ }
23
+
24
+ export const Jdenticon = React.memo(Identicon);
@@ -0,0 +1,59 @@
1
+ // Copyright 2018-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
5
+
6
+ // This has been converted from the original version that can be found at
7
+ //
8
+ // https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
9
+ //
10
+ // Here we have done the following to convert the component -
11
+ // - Converted the code to TypeScript
12
+ // - Removed the oo7 dependencies (since not initialised properly, it makes calls to wrong endpoints)
13
+ // - Remove encoding functionality, these are catered for in the base
14
+ // - Remove copy functionality (this is catered from in the base components)
15
+ // - Split calculations into relevant functions
16
+ // - Move constants to file-level
17
+ // - Overall it is now just a static component, expecting an address as an input value
18
+
19
+ import type { Circle } from '@pezkuwi/ui-shared/icons/types';
20
+ import type { Props } from '../types.js';
21
+
22
+ import React, { useMemo } from 'react';
23
+
24
+ import { polkadotIcon } from '@pezkuwi/ui-shared';
25
+
26
+ function renderCircle ({ cx, cy, fill, r }: Circle, key: number): React.ReactNode {
27
+ return (
28
+ <circle
29
+ cx={cx}
30
+ cy={cy}
31
+ fill={fill}
32
+ key={key}
33
+ r={r}
34
+ />
35
+ );
36
+ }
37
+
38
+ function Identicon ({ address, className = '', isAlternative = false, size, style = {} }: Props): React.ReactElement<Props> {
39
+ const circles = useMemo(
40
+ () => polkadotIcon(address, { isAlternative }),
41
+ [address, isAlternative]
42
+ );
43
+
44
+ return (
45
+ <svg
46
+ className={className}
47
+ height={size}
48
+ id={address}
49
+ name={address}
50
+ style={style}
51
+ viewBox='0 0 64 64'
52
+ width={size}
53
+ >
54
+ {circles.map(renderCircle)}
55
+ </svg>
56
+ );
57
+ }
58
+
59
+ export const Polkadot = React.memo(Identicon);
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { Beachball } from './Beachball.js';
5
+ export { Empty } from './Empty.js';
6
+ export { Ethereum } from './Ethereum.js';
7
+ export { Jdenticon } from './Jdenticon.js';
8
+ export { Polkadot } from './Polkadot.js';
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import './packageDetect.js';
5
+
6
+ import { Identicon } from './bundle.js';
7
+
8
+ export * from './bundle.js';
9
+
10
+ export default Identicon;
@@ -0,0 +1,13 @@
1
+ // Copyright 2017-2026 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+ // (packageInfo imports will be kept as-is, user-editable)
6
+
7
+ import { packageInfo as settingsInfo } from '@pezkuwi/ui-settings/packageInfo';
8
+ import { packageInfo as sharedInfo } from '@pezkuwi/ui-shared/packageInfo';
9
+ import { detectPackage } from '@pezkuwi/util';
10
+
11
+ import { packageInfo } from './packageInfo.js';
12
+
13
+ detectPackage(packageInfo, null, [settingsInfo, sharedInfo]);
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2026 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+
6
+ export const packageInfo = { name: '@pezkuwi/react-identicon', path: 'auto', type: 'auto', version: '3.16.6' };
package/src/styled.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2025 @pezkuwi/react-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { styled } from 'styled-components';