@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.
- package/README.md +34 -0
- package/build/Identicon.d.ts +5 -0
- package/build/Identicon.js +104 -0
- package/build/LICENSE +201 -0
- package/build/README.md +34 -0
- package/build/bundle-pezkuwi-react-identicon.js +2858 -0
- package/build/bundle.d.ts +3 -0
- package/build/bundle.js +3 -0
- package/build/cjs/Identicon.d.ts +5 -0
- package/build/cjs/Identicon.js +108 -0
- package/build/cjs/bundle.d.ts +3 -0
- package/build/cjs/bundle.js +9 -0
- package/build/cjs/icons/Beachball.d.ts +5 -0
- package/build/cjs/icons/Beachball.js +17 -0
- package/build/cjs/icons/Empty.d.ts +5 -0
- package/build/cjs/icons/Empty.js +10 -0
- package/build/cjs/icons/Ethereum.d.ts +5 -0
- package/build/cjs/icons/Ethereum.js +18 -0
- package/build/cjs/icons/Jdenticon.d.ts +5 -0
- package/build/cjs/icons/Jdenticon.js +12 -0
- package/build/cjs/icons/Polkadot.d.ts +5 -0
- package/build/cjs/icons/Polkadot.js +15 -0
- package/build/cjs/icons/index.d.ts +5 -0
- package/build/cjs/icons/index.js +13 -0
- package/build/cjs/index.d.ts +4 -0
- package/build/cjs/index.js +7 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/packageDetect.d.ts +1 -0
- package/build/cjs/packageDetect.js +7 -0
- package/build/cjs/packageInfo.d.ts +6 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/styled.d.ts +1 -0
- package/build/cjs/styled.js +5 -0
- package/build/cjs/types.d.ts +23 -0
- package/build/cjs/types.js +2 -0
- package/build/icons/Beachball.d.ts +5 -0
- package/build/icons/Beachball.js +13 -0
- package/build/icons/Empty.d.ts +5 -0
- package/build/icons/Empty.js +6 -0
- package/build/icons/Ethereum.d.ts +5 -0
- package/build/icons/Ethereum.js +14 -0
- package/build/icons/Jdenticon.d.ts +5 -0
- package/build/icons/Jdenticon.js +8 -0
- package/build/icons/Polkadot.d.ts +5 -0
- package/build/icons/Polkadot.js +11 -0
- package/build/icons/index.d.ts +5 -0
- package/build/icons/index.js +5 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/build/package.json +249 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +5 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/styled.d.ts +1 -0
- package/build/styled.js +1 -0
- package/build/types.d.ts +23 -0
- package/build/types.js +1 -0
- package/build-tsc/Identicon.d.ts +5 -0
- package/build-tsc/bundle.d.ts +3 -0
- package/build-tsc/icons/Beachball.d.ts +5 -0
- package/build-tsc/icons/Empty.d.ts +5 -0
- package/build-tsc/icons/Ethereum.d.ts +5 -0
- package/build-tsc/icons/Jdenticon.d.ts +5 -0
- package/build-tsc/icons/Polkadot.d.ts +5 -0
- package/build-tsc/icons/index.d.ts +5 -0
- package/build-tsc/index.d.ts +4 -0
- package/build-tsc/packageDetect.d.ts +1 -0
- package/build-tsc/packageInfo.d.ts +6 -0
- package/build-tsc/styled.d.ts +1 -0
- package/build-tsc/types.d.ts +23 -0
- package/build-tsc-cjs/Identicon.js +108 -0
- package/build-tsc-cjs/bundle.js +9 -0
- package/build-tsc-cjs/icons/Beachball.js +17 -0
- package/build-tsc-cjs/icons/Empty.js +10 -0
- package/build-tsc-cjs/icons/Ethereum.js +18 -0
- package/build-tsc-cjs/icons/Jdenticon.js +12 -0
- package/build-tsc-cjs/icons/Polkadot.js +15 -0
- package/build-tsc-cjs/icons/index.js +13 -0
- package/build-tsc-cjs/index.js +7 -0
- package/build-tsc-cjs/packageDetect.js +7 -0
- package/build-tsc-cjs/packageInfo.js +4 -0
- package/build-tsc-cjs/styled.js +5 -0
- package/build-tsc-cjs/types.js +2 -0
- package/build-tsc-esm/Identicon.js +104 -0
- package/build-tsc-esm/bundle.js +3 -0
- package/build-tsc-esm/icons/Beachball.js +13 -0
- package/build-tsc-esm/icons/Empty.js +6 -0
- package/build-tsc-esm/icons/Ethereum.js +14 -0
- package/build-tsc-esm/icons/Jdenticon.js +8 -0
- package/build-tsc-esm/icons/Polkadot.js +11 -0
- package/build-tsc-esm/icons/index.js +5 -0
- package/build-tsc-esm/index.js +4 -0
- package/build-tsc-esm/packageDetect.js +5 -0
- package/build-tsc-esm/packageInfo.js +1 -0
- package/build-tsc-esm/styled.js +1 -0
- package/build-tsc-esm/types.js +1 -0
- package/demo.png +0 -0
- package/index.html +17 -0
- package/package.json +48 -0
- package/src/Identicon.tsx +154 -0
- package/src/bundle.ts +6 -0
- package/src/icons/Beachball.tsx +32 -0
- package/src/icons/Empty.tsx +20 -0
- package/src/icons/Ethereum.tsx +37 -0
- package/src/icons/Jdenticon.tsx +24 -0
- package/src/icons/Polkadot.tsx +59 -0
- package/src/icons/index.ts +8 -0
- package/src/index.ts +10 -0
- package/src/packageDetect.ts +13 -0
- package/src/packageInfo.ts +6 -0
- package/src/styled.ts +4 -0
- package/src/types.ts +30 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.build.tsbuildinfo +1 -0
package/build/bundle.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Identicon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const react_copy_to_clipboard_1 = tslib_1.__importDefault(require("react-copy-to-clipboard"));
|
|
8
|
+
const ui_settings_1 = require("@pezkuwi/ui-settings");
|
|
9
|
+
const util_1 = require("@pezkuwi/util");
|
|
10
|
+
const util_crypto_1 = require("@pezkuwi/util-crypto");
|
|
11
|
+
const index_js_1 = require("./icons/index.js");
|
|
12
|
+
const styled_js_1 = require("./styled.js");
|
|
13
|
+
const Fallback = index_js_1.Beachball;
|
|
14
|
+
const DEFAULT_SIZE = 64;
|
|
15
|
+
const Components = {
|
|
16
|
+
beachball: index_js_1.Beachball,
|
|
17
|
+
empty: index_js_1.Empty,
|
|
18
|
+
ethereum: index_js_1.Ethereum,
|
|
19
|
+
jdenticon: index_js_1.Jdenticon,
|
|
20
|
+
polkadot: index_js_1.Polkadot,
|
|
21
|
+
substrate: index_js_1.Jdenticon
|
|
22
|
+
};
|
|
23
|
+
class BaseIcon extends react_1.default.PureComponent {
|
|
24
|
+
state = {
|
|
25
|
+
address: '',
|
|
26
|
+
publicKey: '0x'
|
|
27
|
+
};
|
|
28
|
+
static prefix = undefined;
|
|
29
|
+
static setDefaultPrefix(prefix) {
|
|
30
|
+
BaseIcon.prefix = prefix;
|
|
31
|
+
}
|
|
32
|
+
static getDerivedStateFromProps({ prefix = BaseIcon.prefix, theme, value }, prevState) {
|
|
33
|
+
if (theme === 'ethereum') {
|
|
34
|
+
const address = (0, util_1.isU8a)(value)
|
|
35
|
+
? (0, util_crypto_1.ethereumEncode)(value)
|
|
36
|
+
: value || '';
|
|
37
|
+
return { address, publicKey: '' };
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const address = (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
|
|
41
|
+
? (0, util_crypto_1.encodeAddress)(value, prefix)
|
|
42
|
+
: (value || '');
|
|
43
|
+
const publicKey = (0, util_1.u8aToHex)((0, util_crypto_1.decodeAddress)(address, false, prefix));
|
|
44
|
+
return address === prevState.address
|
|
45
|
+
? null
|
|
46
|
+
: {
|
|
47
|
+
address,
|
|
48
|
+
publicKey
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return {
|
|
53
|
+
address: '',
|
|
54
|
+
publicKey: '0x'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const { address } = this.state;
|
|
60
|
+
const wrapped = this.getWrapped(this.state, this.props);
|
|
61
|
+
return !address
|
|
62
|
+
? wrapped
|
|
63
|
+
: ((0, jsx_runtime_1.jsx)(react_copy_to_clipboard_1.default, { onCopy: this.onCopy, text: address, children: wrapped }));
|
|
64
|
+
}
|
|
65
|
+
getWrapped({ address, publicKey }, { Custom }) {
|
|
66
|
+
const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style = {}, theme = ui_settings_1.settings.icon } = this.props;
|
|
67
|
+
const Component = !address
|
|
68
|
+
? index_js_1.Empty
|
|
69
|
+
: Custom || Components[theme === 'default' ? ui_settings_1.ICON_DEFAULT_HOST : theme] || Fallback;
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(StyledDiv, { className: `ui--IdentityIcon ${className}`, style: style, children: (0, jsx_runtime_1.jsx)(Component, { address: address, className: isHighlight ? 'highlight' : '', isAlternative: isAlternative, publicKey: publicKey, size: size }) }, address));
|
|
71
|
+
}
|
|
72
|
+
onCopy = () => {
|
|
73
|
+
const { onCopy } = this.props;
|
|
74
|
+
const { address } = this.state;
|
|
75
|
+
if (address && onCopy) {
|
|
76
|
+
onCopy(address);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function Icon(props) {
|
|
81
|
+
return (0, jsx_runtime_1.jsx)(BaseIcon, { ...props });
|
|
82
|
+
}
|
|
83
|
+
const StyledDiv = styled_js_1.styled.div `
|
|
84
|
+
cursor: copy;
|
|
85
|
+
display: inline-block;
|
|
86
|
+
line-height: 0;
|
|
87
|
+
|
|
88
|
+
> .container {
|
|
89
|
+
position: relative;
|
|
90
|
+
|
|
91
|
+
> div,
|
|
92
|
+
> svg {
|
|
93
|
+
position: relative;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.highlight:before {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
right: 0;
|
|
101
|
+
bottom: 0;
|
|
102
|
+
border-radius: 50%;
|
|
103
|
+
box-shadow: 0 0 5px 2px #aaa;
|
|
104
|
+
content: '';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
exports.Identicon = react_1.default.memo(Icon);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageInfo = exports.Identicon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./icons/index.js"), exports);
|
|
6
|
+
var Identicon_js_1 = require("./Identicon.js");
|
|
7
|
+
Object.defineProperty(exports, "Identicon", { enumerable: true, get: function () { return Identicon_js_1.Identicon; } });
|
|
8
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
9
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Beachball = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
8
|
+
function Identicon({ address, className = '', size, style = {} }) {
|
|
9
|
+
const updateElem = (0, react_1.useCallback)((node) => {
|
|
10
|
+
if (node) {
|
|
11
|
+
node.innerHTML = '';
|
|
12
|
+
node.appendChild((0, ui_shared_1.beachballIcon)(address, { isAlternative: false, size }));
|
|
13
|
+
}
|
|
14
|
+
}, [address, size]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: className, ref: updateElem, style: style }));
|
|
16
|
+
}
|
|
17
|
+
exports.Beachball = react_1.default.memo(Identicon);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Empty = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
function Identicon({ className = '', size, style = {} }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("svg", { className: className, height: size, style: style, viewBox: '0 0 64 64', width: size }));
|
|
9
|
+
}
|
|
10
|
+
exports.Empty = react_1.default.memo(Identicon);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ethereum = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const ethereum_blockies_base64_1 = tslib_1.__importDefault(require("ethereum-blockies-base64"));
|
|
7
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
+
const styled_js_1 = require("../styled.js");
|
|
9
|
+
function Identicon({ address, className = '', size, style = {} }) {
|
|
10
|
+
const imgSrc = (0, react_1.useMemo)(() => (0, ethereum_blockies_base64_1.default)(address), [address]);
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(StyledImg, { className: className, size: size, src: imgSrc, style: style }));
|
|
12
|
+
}
|
|
13
|
+
const StyledImg = styled_js_1.styled.img(({ size }) => `
|
|
14
|
+
display: block;
|
|
15
|
+
height: ${size}px;
|
|
16
|
+
width: ${size}px;
|
|
17
|
+
`);
|
|
18
|
+
exports.Ethereum = react_1.default.memo(Identicon);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Jdenticon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const jdenticon = tslib_1.__importStar(require("jdenticon"));
|
|
7
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
+
function Identicon({ className = '', publicKey, size, style = {} }) {
|
|
9
|
+
const html = (0, react_1.useMemo)(() => ({ __html: jdenticon.toSvg(publicKey.substring(2), size) }), [publicKey, size]);
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: className, dangerouslySetInnerHTML: html, style: style }));
|
|
11
|
+
}
|
|
12
|
+
exports.Jdenticon = react_1.default.memo(Identicon);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Props } from '../types.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function Identicon({ address, className, isAlternative, size, style }: Props): React.ReactElement<Props>;
|
|
4
|
+
export declare const Polkadot: React.MemoExoticComponent<typeof Identicon>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Polkadot = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
8
|
+
function renderCircle({ cx, cy, fill, r }, key) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)("circle", { cx: cx, cy: cy, fill: fill, r: r }, key));
|
|
10
|
+
}
|
|
11
|
+
function Identicon({ address, className = '', isAlternative = false, size, style = {} }) {
|
|
12
|
+
const circles = (0, react_1.useMemo)(() => (0, ui_shared_1.polkadotIcon)(address, { isAlternative }), [address, isAlternative]);
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("svg", { className: className, height: size, id: address, name: address, style: style, viewBox: '0 0 64 64', width: size, children: circles.map(renderCircle) }));
|
|
14
|
+
}
|
|
15
|
+
exports.Polkadot = react_1.default.memo(Identicon);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Polkadot = exports.Jdenticon = exports.Ethereum = exports.Empty = exports.Beachball = void 0;
|
|
4
|
+
var Beachball_js_1 = require("./Beachball.js");
|
|
5
|
+
Object.defineProperty(exports, "Beachball", { enumerable: true, get: function () { return Beachball_js_1.Beachball; } });
|
|
6
|
+
var Empty_js_1 = require("./Empty.js");
|
|
7
|
+
Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return Empty_js_1.Empty; } });
|
|
8
|
+
var Ethereum_js_1 = require("./Ethereum.js");
|
|
9
|
+
Object.defineProperty(exports, "Ethereum", { enumerable: true, get: function () { return Ethereum_js_1.Ethereum; } });
|
|
10
|
+
var Jdenticon_js_1 = require("./Jdenticon.js");
|
|
11
|
+
Object.defineProperty(exports, "Jdenticon", { enumerable: true, get: function () { return Jdenticon_js_1.Jdenticon; } });
|
|
12
|
+
var Polkadot_js_1 = require("./Polkadot.js");
|
|
13
|
+
Object.defineProperty(exports, "Polkadot", { enumerable: true, get: function () { return Polkadot_js_1.Polkadot; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
require("./packageDetect.js");
|
|
5
|
+
const bundle_js_1 = require("./bundle.js");
|
|
6
|
+
tslib_1.__exportStar(require("./bundle.js"), exports);
|
|
7
|
+
exports.default = bundle_js_1.Identicon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const packageInfo_1 = require("@pezkuwi/ui-settings/cjs/packageInfo");
|
|
4
|
+
const packageInfo_2 = require("@pezkuwi/ui-shared/cjs/packageInfo");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
+
(0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, [packageInfo_1.packageInfo, packageInfo_2.packageInfo]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { styled } from 'styled-components';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.styled = void 0;
|
|
4
|
+
var styled_components_1 = require("styled-components");
|
|
5
|
+
Object.defineProperty(exports, "styled", { enumerable: true, get: function () { return styled_components_1.styled; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { Prefix } from '@pezkuwi/util-crypto/address/types';
|
|
3
|
+
export interface BaseProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
export interface Props extends BaseProps {
|
|
8
|
+
address: string;
|
|
9
|
+
isAlternative?: boolean | undefined;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
size: number;
|
|
12
|
+
}
|
|
13
|
+
export interface IdentityProps extends BaseProps {
|
|
14
|
+
Custom?: React.ComponentType<Props>;
|
|
15
|
+
isAlternative?: boolean;
|
|
16
|
+
isHighlight?: boolean;
|
|
17
|
+
onCopy?: (value: string) => void;
|
|
18
|
+
prefix?: Prefix;
|
|
19
|
+
size?: number;
|
|
20
|
+
theme?: IconTheme;
|
|
21
|
+
value?: string | Uint8Array | null;
|
|
22
|
+
}
|
|
23
|
+
export type IconTheme = 'beachball' | 'empty' | 'ethereum' | 'jdenticon' | 'polkadot' | 'substrate';
|
|
@@ -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,5 @@
|
|
|
1
|
+
import type { Props } from '../types.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function Identicon({ address, className, isAlternative, size, style }: Props): React.ReactElement<Props>;
|
|
4
|
+
export declare const Polkadot: React.MemoExoticComponent<typeof Identicon>;
|
|
5
|
+
export {};
|
|
@@ -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);
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED