@xyo-network/react-chain-blockies 1.20.15 → 1.20.16
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 +9 -433
- package/package.json +24 -24
- package/src/components/blockies/Account.tsx +0 -16
- package/src/components/blockies/Avatar.stories.tsx +0 -21
- package/src/components/blockies/Avatar.tsx +0 -93
- package/src/components/blockies/blockies.ts +0 -128
- package/src/components/blockies/index.ts +0 -3
- package/src/components/index.ts +0 -1
- package/src/index.ts +0 -1
package/README.md
CHANGED
|
@@ -1,448 +1,24 @@
|
|
|
1
1
|
# @xyo-network/react-chain-blockies
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-downloads-badge][]][npm-link]
|
|
7
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
8
|
-
[![npm-license-badge][]](LICENSE)
|
|
9
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> XYO Layer One React SDK Blockies
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
## Install
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Reference
|
|
16
|
-
|
|
17
|
-
**@xyo-network/react-chain-blockies**
|
|
18
|
-
|
|
19
|
-
***
|
|
20
|
-
|
|
21
|
-
## Interfaces
|
|
22
|
-
|
|
23
|
-
- [BlockiesAccountProps](#interfaces/BlockiesAccountProps)
|
|
24
|
-
- [BlockiesAvatarProps](#interfaces/BlockiesAvatarProps)
|
|
25
|
-
- [BlockiesAvatarAddressProps](#interfaces/BlockiesAvatarAddressProps)
|
|
26
|
-
- [BlockiesAvatarAddressApprovedProps](#interfaces/BlockiesAvatarAddressApprovedProps)
|
|
27
|
-
- [BlockiesOptions](#interfaces/BlockiesOptions)
|
|
28
|
-
|
|
29
|
-
## Variables
|
|
30
|
-
|
|
31
|
-
- [BlockiesAccount](#variables/BlockiesAccount)
|
|
32
|
-
- [BlockiesAvatar](#variables/BlockiesAvatar)
|
|
33
|
-
- [BlockiesAvatarAddress](#variables/BlockiesAvatarAddress)
|
|
34
|
-
- [BlockiesAvatarAddressApproved](#variables/BlockiesAvatarAddressApproved)
|
|
35
|
-
|
|
36
|
-
## Functions
|
|
37
|
-
|
|
38
|
-
- [buildOpts](#functions/buildOpts)
|
|
39
|
-
- [renderIcon](#functions/renderIcon)
|
|
40
|
-
- [createIcon](#functions/createIcon)
|
|
41
|
-
|
|
42
|
-
### functions
|
|
43
|
-
|
|
44
|
-
### <a id="buildOpts"></a>buildOpts
|
|
45
|
-
|
|
46
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
47
|
-
|
|
48
|
-
***
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
function buildOpts(opts): BlockiesOptions;
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Parameters
|
|
55
|
-
|
|
56
|
-
### opts
|
|
57
|
-
|
|
58
|
-
`Partial`\<[`BlockiesOptions`](#../interfaces/BlockiesOptions)\>
|
|
59
|
-
|
|
60
|
-
## Returns
|
|
61
|
-
|
|
62
|
-
[`BlockiesOptions`](#../interfaces/BlockiesOptions)
|
|
63
|
-
|
|
64
|
-
### <a id="createIcon"></a>createIcon
|
|
65
|
-
|
|
66
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
67
|
-
|
|
68
|
-
***
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
function createIcon(opts): HTMLCanvasElement;
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Parameters
|
|
75
|
-
|
|
76
|
-
### opts
|
|
77
|
-
|
|
78
|
-
`Partial`\<[`BlockiesOptions`](#../interfaces/BlockiesOptions)\>
|
|
79
|
-
|
|
80
|
-
## Returns
|
|
81
|
-
|
|
82
|
-
`HTMLCanvasElement`
|
|
83
|
-
|
|
84
|
-
### <a id="renderIcon"></a>renderIcon
|
|
85
|
-
|
|
86
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
87
|
-
|
|
88
|
-
***
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
function renderIcon(opts, canvas): HTMLCanvasElement;
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Parameters
|
|
95
|
-
|
|
96
|
-
### opts
|
|
97
|
-
|
|
98
|
-
`Partial`\<[`BlockiesOptions`](#../interfaces/BlockiesOptions)\>
|
|
99
|
-
|
|
100
|
-
### canvas
|
|
101
|
-
|
|
102
|
-
`HTMLCanvasElement`
|
|
103
|
-
|
|
104
|
-
## Returns
|
|
105
|
-
|
|
106
|
-
`HTMLCanvasElement`
|
|
107
|
-
|
|
108
|
-
### interfaces
|
|
109
|
-
|
|
110
|
-
### <a id="BlockiesAccountProps"></a>BlockiesAccountProps
|
|
111
|
-
|
|
112
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
113
|
-
|
|
114
|
-
***
|
|
115
|
-
|
|
116
|
-
## Extends
|
|
117
|
-
|
|
118
|
-
- `Partial`\<[`BlockiesOptions`](#BlockiesOptions)\>
|
|
119
|
-
|
|
120
|
-
## Properties
|
|
121
|
-
|
|
122
|
-
### bgcolor?
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
optional bgcolor: string;
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Inherited from
|
|
129
|
-
|
|
130
|
-
[`BlockiesOptions`](#BlockiesOptions).[`bgcolor`](BlockiesOptions.md#bgcolor)
|
|
131
|
-
|
|
132
|
-
***
|
|
133
|
-
|
|
134
|
-
### color?
|
|
135
|
-
|
|
136
|
-
```ts
|
|
137
|
-
optional color: string;
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Inherited from
|
|
141
|
-
|
|
142
|
-
[`BlockiesOptions`](#BlockiesOptions).[`color`](BlockiesOptions.md#color)
|
|
143
|
-
|
|
144
|
-
***
|
|
145
|
-
|
|
146
|
-
### scale?
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
optional scale: number;
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Inherited from
|
|
153
|
-
|
|
154
|
-
[`BlockiesOptions`](#BlockiesOptions).[`scale`](BlockiesOptions.md#scale)
|
|
155
|
-
|
|
156
|
-
***
|
|
157
|
-
|
|
158
|
-
### seed?
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
optional seed: string;
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Inherited from
|
|
165
|
-
|
|
166
|
-
[`BlockiesOptions`](#BlockiesOptions).[`seed`](BlockiesOptions.md#seed)
|
|
167
|
-
|
|
168
|
-
***
|
|
169
|
-
|
|
170
|
-
### size?
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
optional size: number;
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Inherited from
|
|
177
|
-
|
|
178
|
-
[`BlockiesOptions`](#BlockiesOptions).[`size`](BlockiesOptions.md#size)
|
|
179
|
-
|
|
180
|
-
***
|
|
181
|
-
|
|
182
|
-
### spotcolor?
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
optional spotcolor: string;
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Inherited from
|
|
189
|
-
|
|
190
|
-
[`BlockiesOptions`](#BlockiesOptions).[`spotcolor`](BlockiesOptions.md#spotcolor)
|
|
191
|
-
|
|
192
|
-
### <a id="BlockiesAvatarAddressApprovedProps"></a>BlockiesAvatarAddressApprovedProps
|
|
193
|
-
|
|
194
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
195
|
-
|
|
196
|
-
***
|
|
197
|
-
|
|
198
|
-
## Extends
|
|
199
|
-
|
|
200
|
-
- [`BlockiesAvatarAddressProps`](#BlockiesAvatarAddressProps)
|
|
201
|
-
|
|
202
|
-
## Properties
|
|
203
|
-
|
|
204
|
-
### address?
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
optional address: string;
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
The Address to display
|
|
211
|
-
|
|
212
|
-
### Inherited from
|
|
213
|
-
|
|
214
|
-
[`BlockiesAvatarAddressProps`](#BlockiesAvatarAddressProps).[`address`](BlockiesAvatarAddressProps.md#address)
|
|
215
|
-
|
|
216
|
-
***
|
|
217
|
-
|
|
218
|
-
### borderSizeFactor?
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
|
-
optional borderSizeFactor: number;
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Size of the border is the size prop * borderSizeFactor and rounded up
|
|
225
|
-
|
|
226
|
-
### Inherited from
|
|
227
|
-
|
|
228
|
-
[`BlockiesAvatarAddressProps`](#BlockiesAvatarAddressProps).[`borderSizeFactor`](BlockiesAvatarAddressProps.md#bordersizefactor)
|
|
229
|
-
|
|
230
|
-
***
|
|
231
|
-
|
|
232
|
-
### size?
|
|
233
|
-
|
|
234
|
-
```ts
|
|
235
|
-
optional size: number;
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
The size of the avatar in pixels, defaults to 24
|
|
239
|
-
|
|
240
|
-
### Inherited from
|
|
241
|
-
|
|
242
|
-
[`BlockiesAvatarAddressProps`](#BlockiesAvatarAddressProps).[`size`](BlockiesAvatarAddressProps.md#size)
|
|
243
|
-
|
|
244
|
-
***
|
|
245
|
-
|
|
246
|
-
### approved?
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
optional approved: boolean;
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Whether to show the approved badge
|
|
253
|
-
|
|
254
|
-
***
|
|
255
|
-
|
|
256
|
-
### badgeVariant?
|
|
257
|
-
|
|
258
|
-
```ts
|
|
259
|
-
optional badgeVariant: OverridableStringUnion<"standard" | "dot", BadgePropsVariantOverrides>;
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### <a id="BlockiesAvatarAddressProps"></a>BlockiesAvatarAddressProps
|
|
263
|
-
|
|
264
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
265
|
-
|
|
266
|
-
***
|
|
267
|
-
|
|
268
|
-
## Extends
|
|
269
|
-
|
|
270
|
-
- `AvatarProps`
|
|
271
|
-
|
|
272
|
-
## Extended by
|
|
273
|
-
|
|
274
|
-
- [`BlockiesAvatarAddressApprovedProps`](#BlockiesAvatarAddressApprovedProps)
|
|
275
|
-
|
|
276
|
-
## Properties
|
|
277
|
-
|
|
278
|
-
### address?
|
|
279
|
-
|
|
280
|
-
```ts
|
|
281
|
-
optional address: string;
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
The Address to display
|
|
285
|
-
|
|
286
|
-
***
|
|
287
|
-
|
|
288
|
-
### borderSizeFactor?
|
|
289
|
-
|
|
290
|
-
```ts
|
|
291
|
-
optional borderSizeFactor: number;
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
Size of the border is the size prop * borderSizeFactor and rounded up
|
|
295
|
-
|
|
296
|
-
***
|
|
297
|
-
|
|
298
|
-
### size?
|
|
299
|
-
|
|
300
|
-
```ts
|
|
301
|
-
optional size: number;
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
The size of the avatar in pixels, defaults to 24
|
|
305
|
-
|
|
306
|
-
### <a id="BlockiesAvatarProps"></a>BlockiesAvatarProps
|
|
307
|
-
|
|
308
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
309
|
-
|
|
310
|
-
***
|
|
311
|
-
|
|
312
|
-
## Extends
|
|
313
|
-
|
|
314
|
-
- `AvatarProps`
|
|
315
|
-
|
|
316
|
-
## Properties
|
|
317
|
-
|
|
318
|
-
### blockiesOptions?
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
optional blockiesOptions: Partial<BlockiesOptions>;
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### <a id="BlockiesOptions"></a>BlockiesOptions
|
|
325
|
-
|
|
326
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
327
|
-
|
|
328
|
-
***
|
|
329
|
-
|
|
330
|
-
## Properties
|
|
331
|
-
|
|
332
|
-
### bgcolor
|
|
333
|
-
|
|
334
|
-
```ts
|
|
335
|
-
bgcolor: string;
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
***
|
|
339
|
-
|
|
340
|
-
### color
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
color: string;
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
***
|
|
347
|
-
|
|
348
|
-
### scale
|
|
349
|
-
|
|
350
|
-
```ts
|
|
351
|
-
scale: number;
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
***
|
|
355
|
-
|
|
356
|
-
### seed
|
|
357
|
-
|
|
358
|
-
```ts
|
|
359
|
-
seed: string;
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
***
|
|
363
|
-
|
|
364
|
-
### size
|
|
365
|
-
|
|
366
|
-
```ts
|
|
367
|
-
size: number;
|
|
10
|
+
```sh
|
|
11
|
+
{{pm}} add {{name}}
|
|
368
12
|
```
|
|
369
13
|
|
|
370
|
-
***
|
|
371
|
-
|
|
372
|
-
### spotcolor
|
|
373
|
-
|
|
374
|
-
```ts
|
|
375
|
-
spotcolor: string;
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### variables
|
|
379
|
-
|
|
380
|
-
### <a id="BlockiesAccount"></a>BlockiesAccount
|
|
381
|
-
|
|
382
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
383
|
-
|
|
384
|
-
***
|
|
385
|
-
|
|
386
|
-
```ts
|
|
387
|
-
const BlockiesAccount: React.FC<BlockiesAccountProps>;
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### <a id="BlockiesAvatar"></a>BlockiesAvatar
|
|
391
|
-
|
|
392
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
393
|
-
|
|
394
|
-
***
|
|
395
|
-
|
|
396
|
-
```ts
|
|
397
|
-
const BlockiesAvatar: React.FC<BlockiesAvatarProps>;
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
### <a id="BlockiesAvatarAddress"></a>BlockiesAvatarAddress
|
|
401
|
-
|
|
402
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
403
|
-
|
|
404
|
-
***
|
|
405
|
-
|
|
406
|
-
```ts
|
|
407
|
-
const BlockiesAvatarAddress: React.FC<BlockiesAvatarAddressProps>;
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
### <a id="BlockiesAvatarAddressApproved"></a>BlockiesAvatarAddressApproved
|
|
411
|
-
|
|
412
|
-
[**@xyo-network/react-chain-blockies**](#../README)
|
|
413
|
-
|
|
414
|
-
***
|
|
415
|
-
|
|
416
|
-
```ts
|
|
417
|
-
const BlockiesAvatarAddressApproved: React.FC<BlockiesAvatarAddressApprovedProps>;
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
## Maintainers
|
|
422
|
-
|
|
423
|
-
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
424
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
425
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
426
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
427
14
|
|
|
428
15
|
## License
|
|
429
16
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
## Credits
|
|
17
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
433
18
|
|
|
434
|
-
[Made with 🔥 and ❄️ by XYO](https://xyo.network)
|
|
435
19
|
|
|
436
|
-
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
437
20
|
|
|
438
21
|
[npm-badge]: https://img.shields.io/npm/v/@xyo-network/react-chain-blockies.svg
|
|
439
22
|
[npm-link]: https://www.npmjs.com/package/@xyo-network/react-chain-blockies
|
|
440
|
-
|
|
441
|
-
[
|
|
442
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xyo-network/react-chain-blockies
|
|
443
|
-
|
|
444
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xyo-network/react-chain-blockies/badge
|
|
445
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xyo-network/react-chain-blockies
|
|
446
|
-
|
|
447
|
-
[socket-badge]: https://socket.dev/api/badge/npm/package/@xyo-network/react-chain-blockies
|
|
448
|
-
[socket-link]: https://socket.dev/npm/package/@xyo-network/react-chain-blockies
|
|
23
|
+
[license-badge]: https://img.shields.io/npm/l/@xyo-network/react-chain-blockies.svg
|
|
24
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/react-chain-blockies",
|
|
4
|
-
"version": "1.20.
|
|
4
|
+
"version": "1.20.16",
|
|
5
5
|
"description": "XYO Layer One React SDK Blockies",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -25,58 +25,58 @@
|
|
|
25
25
|
"types": "./dist/browser/index.d.ts",
|
|
26
26
|
"browser": {
|
|
27
27
|
"types": "./dist/browser/index.d.ts",
|
|
28
|
-
"source": "./src/index.ts",
|
|
29
28
|
"default": "./dist/browser/index.mjs"
|
|
30
29
|
},
|
|
31
|
-
"source": "./src/index.ts",
|
|
32
30
|
"default": "./dist/browser/index.mjs"
|
|
33
31
|
},
|
|
34
32
|
"./package.json": "./package.json"
|
|
35
33
|
},
|
|
36
34
|
"module": "./dist/browser/index.mjs",
|
|
37
|
-
"source": "./src/index.ts",
|
|
38
35
|
"types": "./dist/browser/index.d.ts",
|
|
39
36
|
"files": [
|
|
40
37
|
"dist",
|
|
41
|
-
"src",
|
|
42
38
|
"!**/*.bench.*",
|
|
43
39
|
"!**/*.spec.*",
|
|
44
|
-
"!**/*.test.*"
|
|
40
|
+
"!**/*.test.*",
|
|
41
|
+
"README.md"
|
|
45
42
|
],
|
|
46
43
|
"dependencies": {
|
|
47
44
|
"@mui/icons-material": "~7.3.9",
|
|
48
|
-
"@xylabs/react-theme": "~7.1.
|
|
45
|
+
"@xylabs/react-theme": "~7.1.20"
|
|
49
46
|
},
|
|
50
47
|
"devDependencies": {
|
|
51
48
|
"@emotion/react": "~11.14.0",
|
|
52
49
|
"@emotion/styled": "~11.14.1",
|
|
53
50
|
"@mui/material": "~7.3.9",
|
|
54
|
-
"@
|
|
51
|
+
"@opentelemetry/api": "^1",
|
|
52
|
+
"@storybook/react-vite": "^10.3.5",
|
|
53
|
+
"@types/node": "^25.5.2",
|
|
55
54
|
"@types/react": "~19.2.14",
|
|
56
|
-
"@xylabs/
|
|
57
|
-
"@xylabs/
|
|
58
|
-
"@xylabs/
|
|
59
|
-
"@xylabs/
|
|
60
|
-
"@xylabs/tsconfig
|
|
55
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
56
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
57
|
+
"@xylabs/ts-scripts-common": "~7.9.3",
|
|
58
|
+
"@xylabs/ts-scripts-pnpm": "~7.9.3",
|
|
59
|
+
"@xylabs/tsconfig": "~7.9.3",
|
|
60
|
+
"@xylabs/tsconfig-dom": "~7.9.3",
|
|
61
|
+
"@xylabs/tsconfig-react": "~7.9.3",
|
|
62
|
+
"axios": "^1",
|
|
63
|
+
"esbuild": "*",
|
|
64
|
+
"pako": "~2.1.0",
|
|
61
65
|
"react": "~19.2.4",
|
|
62
66
|
"react-dom": "~19.2.4",
|
|
63
|
-
"
|
|
64
|
-
"storybook": "^10.3.3",
|
|
67
|
+
"storybook": "^10.3.5",
|
|
65
68
|
"typescript": "~5.9.3",
|
|
66
|
-
"vite": "^8.0.
|
|
69
|
+
"vite": "^8.0.7",
|
|
67
70
|
"zod": "~4.3.6"
|
|
68
71
|
},
|
|
69
72
|
"peerDependencies": {
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"react": "~19",
|
|
75
|
-
"react-dom": "~19",
|
|
76
|
-
"zod": "^4"
|
|
73
|
+
"@mui/material": "~7.3.9",
|
|
74
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
75
|
+
"pako": "~2.1.0",
|
|
76
|
+
"react": "~19.2.4"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
81
|
"docs": "dist/docs.json"
|
|
82
|
-
}
|
|
82
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import type { BlockiesOptions } from './blockies.ts'
|
|
4
|
-
import { createIcon } from './blockies.ts'
|
|
5
|
-
|
|
6
|
-
export interface BlockiesAccountProps extends Partial<BlockiesOptions> {}
|
|
7
|
-
|
|
8
|
-
export const BlockiesAccount: React.FC<BlockiesAccountProps> = ({ ...options }) => {
|
|
9
|
-
const img = useMemo(() => {
|
|
10
|
-
if (options.seed !== undefined) {
|
|
11
|
-
return createIcon(options).toDataURL()
|
|
12
|
-
}
|
|
13
|
-
}, [options])
|
|
14
|
-
|
|
15
|
-
return <img src={img} />
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { BlockiesAvatarAddress } from './Avatar.tsx'
|
|
5
|
-
|
|
6
|
-
const address = '0x1234567890abcdef1234567890abcdef12345678'
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Blockies/Avatar/Address',
|
|
10
|
-
component: BlockiesAvatarAddress,
|
|
11
|
-
} as Meta
|
|
12
|
-
|
|
13
|
-
const Template: StoryFn<typeof BlockiesAvatarAddress> = args => <BlockiesAvatarAddress {...args} />
|
|
14
|
-
|
|
15
|
-
const Default = Template.bind({})
|
|
16
|
-
Default.args = {}
|
|
17
|
-
|
|
18
|
-
const WithValue = Template.bind({})
|
|
19
|
-
WithValue.args = { address }
|
|
20
|
-
|
|
21
|
-
export { Default, WithValue }
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Circle } from '@mui/icons-material'
|
|
2
|
-
import type { AvatarProps, BadgeProps } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
Avatar, Badge, useTheme,
|
|
5
|
-
} from '@mui/material'
|
|
6
|
-
import { grey } from '@mui/material/colors'
|
|
7
|
-
import { alphaCss } from '@xylabs/react-theme'
|
|
8
|
-
import React, { useMemo } from 'react'
|
|
9
|
-
|
|
10
|
-
import type { BlockiesOptions } from './blockies.ts'
|
|
11
|
-
import { createIcon } from './blockies.ts'
|
|
12
|
-
|
|
13
|
-
export interface BlockiesAvatarProps extends AvatarProps {
|
|
14
|
-
blockiesOptions?: Partial<BlockiesOptions>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const BlockiesAvatar: React.FC<BlockiesAvatarProps> = ({ blockiesOptions, ...props }) => {
|
|
18
|
-
const img = useMemo(() => {
|
|
19
|
-
if (blockiesOptions?.seed !== undefined) {
|
|
20
|
-
return createIcon(blockiesOptions).toDataURL()
|
|
21
|
-
}
|
|
22
|
-
}, [blockiesOptions])
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Avatar component="span" src={img} {...props} />
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface BlockiesAvatarAddressProps extends AvatarProps {
|
|
30
|
-
/** The Address to display */
|
|
31
|
-
address?: string
|
|
32
|
-
/** Size of the border is the size prop * borderSizeFactor and rounded up */
|
|
33
|
-
borderSizeFactor?: number
|
|
34
|
-
/** The size of the avatar in pixels, defaults to 24 */
|
|
35
|
-
size?: number
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const BlockiesAvatarAddress: React.FC<BlockiesAvatarAddressProps> = ({
|
|
39
|
-
address, borderSizeFactor = 0.0833, size = 24, sx, ...props
|
|
40
|
-
}) => {
|
|
41
|
-
const theme = useTheme()
|
|
42
|
-
const options = useMemo(() => {
|
|
43
|
-
if (address !== undefined) {
|
|
44
|
-
return { seed: address }
|
|
45
|
-
}
|
|
46
|
-
}, [address])
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<BlockiesAvatar
|
|
50
|
-
blockiesOptions={options}
|
|
51
|
-
sx={{
|
|
52
|
-
width: size,
|
|
53
|
-
height: size,
|
|
54
|
-
border: `${Math.ceil(size * borderSizeFactor)}px solid ${alphaCss(theme.vars?.palette.text.primary ?? grey[500], 0.8)}`,
|
|
55
|
-
...sx,
|
|
56
|
-
}}
|
|
57
|
-
{...props}
|
|
58
|
-
/>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface BlockiesAvatarAddressApprovedProps extends BlockiesAvatarAddressProps {
|
|
63
|
-
/** Whether to show the approved badge */
|
|
64
|
-
approved?: boolean
|
|
65
|
-
badgeVariant?: BadgeProps['variant']
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const BlockiesAvatarAddressApproved: React.FC<BlockiesAvatarAddressApprovedProps> = ({
|
|
69
|
-
approved, badgeVariant, ...props
|
|
70
|
-
}) => {
|
|
71
|
-
const sx = badgeVariant === 'dot'
|
|
72
|
-
? {}
|
|
73
|
-
: {
|
|
74
|
-
bgcolor: 'white', borderRadius: 12, fontSize: '0.83333rem',
|
|
75
|
-
}
|
|
76
|
-
const dotPlacement = badgeVariant === 'dot' ? 3 : 5
|
|
77
|
-
return (
|
|
78
|
-
<Badge
|
|
79
|
-
color={badgeVariant === 'dot' ? 'success' : 'default'}
|
|
80
|
-
variant={badgeVariant}
|
|
81
|
-
invisible={!approved}
|
|
82
|
-
badgeContent={approved ? <Circle color="success" sx={sx} /> : ''}
|
|
83
|
-
sx={{
|
|
84
|
-
'& .MuiBadge-badge': {
|
|
85
|
-
top: dotPlacement,
|
|
86
|
-
right: dotPlacement,
|
|
87
|
-
},
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<BlockiesAvatarAddress {...props} />
|
|
91
|
-
</Badge>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inspired by https://github.com/download13/blockies/blob/master/src/blockies.mjs
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// The random number is a js implementation of the Xorshift PRNG
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
const randomSeed: any[] = Array.from({ length: 4 }) // Xorshift: [x, y, z, w] 32 bit values
|
|
8
|
-
|
|
9
|
-
function seedRandom(seed: string) {
|
|
10
|
-
for (let i = 0; i < randomSeed.length; i++) {
|
|
11
|
-
randomSeed[i] = 0
|
|
12
|
-
}
|
|
13
|
-
for (let i = 0; i < seed.length; i++) {
|
|
14
|
-
randomSeed[i % 4] = ((randomSeed[i % 4] << 5) - randomSeed[i % 4]) + seed.codePointAt(i)!
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function rand() {
|
|
19
|
-
// based on Java's String.hashCode(), expanded to 4 32bit values
|
|
20
|
-
const t = randomSeed[0] ^ (randomSeed[0] << 11)
|
|
21
|
-
|
|
22
|
-
randomSeed[0] = randomSeed[1]
|
|
23
|
-
randomSeed[1] = randomSeed[2]
|
|
24
|
-
randomSeed[2] = randomSeed[3]
|
|
25
|
-
randomSeed[3] = (randomSeed[3] ^ (randomSeed[3] >> 19) ^ t ^ (t >> 8))
|
|
26
|
-
|
|
27
|
-
return (randomSeed[3] >>> 0) / ((1 << 31) >>> 0)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function createColor() {
|
|
31
|
-
// saturation is the whole color spectrum
|
|
32
|
-
const h = Math.floor(rand() * 360)
|
|
33
|
-
// saturation goes from 40 to 100, it avoids greyish colors
|
|
34
|
-
const s = ((rand() * 60) + 40) + '%'
|
|
35
|
-
// lightness can be anything from 0 to 100, but probabilities are a bell curve around 50%
|
|
36
|
-
const l = ((rand() + rand() + rand() + rand()) * 25) + '%'
|
|
37
|
-
|
|
38
|
-
return 'hsl(' + h + ',' + s + ',' + l + ')'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function createImageData(size: number) {
|
|
42
|
-
const width = size // Only support square icons for now
|
|
43
|
-
const height = size
|
|
44
|
-
|
|
45
|
-
const dataWidth = Math.ceil(width / 2)
|
|
46
|
-
const mirrorWidth = width - dataWidth
|
|
47
|
-
|
|
48
|
-
const data = []
|
|
49
|
-
for (let y = 0; y < height; y++) {
|
|
50
|
-
let row = []
|
|
51
|
-
for (let x = 0; x < dataWidth; x++) {
|
|
52
|
-
// this makes foreground and background color to have a 43% (1/2.3) probability
|
|
53
|
-
// spot color has 13% chance
|
|
54
|
-
row[x] = Math.floor(rand() * 2.3)
|
|
55
|
-
}
|
|
56
|
-
const r = row.slice(0, mirrorWidth)
|
|
57
|
-
r.reverse()
|
|
58
|
-
row = [...row, ...r]
|
|
59
|
-
|
|
60
|
-
for (const element of row) {
|
|
61
|
-
data.push(element)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return data
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface BlockiesOptions {
|
|
69
|
-
bgcolor: string
|
|
70
|
-
color: string
|
|
71
|
-
scale: number
|
|
72
|
-
seed: string
|
|
73
|
-
size: number
|
|
74
|
-
spotcolor: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function buildOpts(opts: Partial<BlockiesOptions>): BlockiesOptions {
|
|
78
|
-
const newOpts = {} as BlockiesOptions
|
|
79
|
-
|
|
80
|
-
newOpts.seed = opts.seed ?? Math.floor((Math.random() * Math.pow(10, 16))).toString(16)
|
|
81
|
-
|
|
82
|
-
seedRandom(newOpts.seed)
|
|
83
|
-
|
|
84
|
-
newOpts.size = opts.size ?? 8
|
|
85
|
-
newOpts.scale = opts.scale ?? 4
|
|
86
|
-
newOpts.color = opts.color ?? createColor()
|
|
87
|
-
newOpts.bgcolor = opts.bgcolor ?? createColor()
|
|
88
|
-
newOpts.spotcolor = opts.spotcolor ?? createColor()
|
|
89
|
-
|
|
90
|
-
return newOpts
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function renderIcon(opts: Partial<BlockiesOptions>, canvas: HTMLCanvasElement) {
|
|
94
|
-
const updatedOptions = buildOpts(opts ?? {})
|
|
95
|
-
const imageData = createImageData(updatedOptions.size)
|
|
96
|
-
const width = Math.sqrt(imageData.length)
|
|
97
|
-
|
|
98
|
-
canvas.width = canvas.height = updatedOptions.size * updatedOptions.scale
|
|
99
|
-
|
|
100
|
-
const cc = canvas.getContext('2d')
|
|
101
|
-
if (cc === null) throw new Error('unable to get 2d context')
|
|
102
|
-
cc.fillStyle = updatedOptions.bgcolor
|
|
103
|
-
cc.fillRect(0, 0, canvas.width, canvas.height)
|
|
104
|
-
cc.fillStyle = updatedOptions.color
|
|
105
|
-
|
|
106
|
-
for (const [i, imageDatum] of imageData.entries()) {
|
|
107
|
-
// if data is 0, leave the background
|
|
108
|
-
if (imageDatum > 0) {
|
|
109
|
-
const row = Math.floor(i / width)
|
|
110
|
-
const col = i % width
|
|
111
|
-
|
|
112
|
-
// if data is 2, choose spot color, if 1 choose foreground
|
|
113
|
-
cc.fillStyle = (imageDatum == 1) ? updatedOptions.color : updatedOptions.spotcolor
|
|
114
|
-
|
|
115
|
-
cc.fillRect(col * updatedOptions.scale, row * updatedOptions.scale, updatedOptions.scale, updatedOptions.scale)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return canvas
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function createIcon(opts: Partial<BlockiesOptions>) {
|
|
123
|
-
var canvas = document.createElement('canvas')
|
|
124
|
-
|
|
125
|
-
renderIcon(opts, canvas)
|
|
126
|
-
|
|
127
|
-
return canvas
|
|
128
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './blockies/index.ts'
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components/index.ts'
|