From b43ea0d0b36f6edb023c89934ecf2dcdb0b55b74 Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 11:20:41 +0100
Subject: [PATCH 01/11] docs: added identicons page
---
.vitepress/theme/components/Identicon.vue | 21 +++
.../theme/components/IdenticonBuilder.vue | 138 ++++++++++++++++
.vitepress/theme/style.css | 2 +-
build/ui/identicons.md | 152 ++++++++++++++++++
package.json | 1 +
pnpm-lock.yaml | 8 +
6 files changed, 321 insertions(+), 1 deletion(-)
create mode 100644 .vitepress/theme/components/Identicon.vue
create mode 100644 .vitepress/theme/components/IdenticonBuilder.vue
create mode 100644 build/ui/identicons.md
diff --git a/.vitepress/theme/components/Identicon.vue b/.vitepress/theme/components/Identicon.vue
new file mode 100644
index 0000000..1af7708
--- /dev/null
+++ b/.vitepress/theme/components/Identicon.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+
diff --git a/.vitepress/theme/components/IdenticonBuilder.vue b/.vitepress/theme/components/IdenticonBuilder.vue
new file mode 100644
index 0000000..6acb781
--- /dev/null
+++ b/.vitepress/theme/components/IdenticonBuilder.vue
@@ -0,0 +1,138 @@
+
+
+
+
+
diff --git a/.vitepress/theme/style.css b/.vitepress/theme/style.css
index 9cd9d65..75da832 100644
--- a/.vitepress/theme/style.css
+++ b/.vitepress/theme/style.css
@@ -101,7 +101,7 @@ h2 {
}
.nq-subline {
- --uno: nq-subline text-neutral-700 mt-24;
+ --uno: nq-subline text-neutral-700 mt-24 text-20|22;
}
.VPHome {
diff --git a/build/ui/identicons.md b/build/ui/identicons.md
new file mode 100644
index 0000000..3b6d6dc
--- /dev/null
+++ b/build/ui/identicons.md
@@ -0,0 +1,152 @@
+# Nimiq Identicons
+
+
+
+A simple, visually recognizable way to verify addresses.{.nq-subline}
+
+
+
+## More than 9 Million Identicons!
+
+Each Identicon is a unique combination of colors and shapes based on an account's hash, providing instant visual confirmation.
+
+
+
+
+
+## Installation
+
+To start using Nimiq Identicons in your project, run:
+
+::: code-group
+
+```bash [npm]
+npm install identicons-esm
+```
+
+```bash [yarn]
+yarn add identicons-esm
+```
+
+```bash [pnpm]
+pnpm add identicons-esm
+```
+
+```bash [bun]
+bun add identicons-esm
+```
+:::
+
+## Basic Usage
+
+Import and create an identicon using `createIdenticon`:
+
+```ts
+import { createIdenticon } from 'identicons-esm'
+
+const input = 'Your input here'
+const svg = await createIdenticon(input)
+```
+
+## Customization
+
+For specific colors or sections of the identicon, use `getIdenticonsParams`:
+
+```ts
+import { getIdenticonsParams } from 'identicons-esm'
+
+const input = 'Your input here'
+const { colors, sections } = await getIdenticonsParams(input)
+
+// colors.background, colors.main, colors.accent
+// sections.top, sections.bottom, sections.sides, sections.face (SVG paths)
+```
+
+## Migration from Legacy
+
+This module has updated performance and packaging over the legacy version.
+
+
+
+
+
+### Generating a SVG {.nq-no-prose}
+
+
+
+
+
+#### Old {.mt-0}
+
+```js
+import Identicons from '@nimiq/identicons/dist/identicons.min.js'
+IdenticonsLegacy.svgPath = '@nimiq/identicons/dist/identicons.min.svg'
+
+const input = 'Your input here'
+const svg = await Identicons.svg(input)
+```
+
+#### New {.mt-0}
+
+```js
+import { createIdenticon } from 'identicons-esm'
+
+const input = 'Your input here'
+const svg = await createIdenticon(input)
+```
+
+
+
+
+
+
+
+
+
+### Generating a Data URI {.nq-no-prose}
+
+
+
+
+
+#### Old {.mt-0}
+
+```js
+import Identicons from '@nimiq/identicons/dist/identicons.min.js'
+IdenticonsLegacy.svgPath = '@nimiq/identicons/dist/identicons.min.svg'
+
+const input = 'Your input here'
+const svg = await Identicons.toDataUri(input)
+```
+
+#### New {.mt-0}
+
+```ts
+import { createIdenticon } from 'identicons-esm'
+
+const input = 'Your input here'
+const svg = await createIdenticon(input, { format: 'image/svg+xml' })
+```
+
+
+
+
+
+### Discontiuned functions
+
+There are functions in the original library that are not included in this implementation due to lack of use. These functions are:
+
+- `makeLetterHash`
+- `wordsByEntropy`
+- `Identicons.render`
+- `Identicons.image`
+- `Identicons.placeholder`
diff --git a/package.json b/package.json
index 6da6fdb..ea8af58 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"@unocss/reset": "^0.63.6",
"@vueuse/core": "^11.1.0",
"iconify-icon": "^2.1.0",
+ "identicons-esm": "^0.0.3",
"json2md": "^2.0.1",
"jszip": "^3.10.1",
"markdown-it-mathjax3": "^4.3.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9cb72ef..08c2262 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -26,6 +26,9 @@ importers:
iconify-icon:
specifier: ^2.1.0
version: 2.1.0
+ identicons-esm:
+ specifier: ^0.0.3
+ version: 0.0.3
json2md:
specifier: ^2.0.1
version: 2.0.1
@@ -2696,6 +2699,9 @@ packages:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
+ identicons-esm@0.0.3:
+ resolution: {integrity: sha512-/YlnqD6tM93r4+ZaU2dWz1zA996vuuL+QSKBBD9ST1JDvAKqmwlQt3yvEOKe6K4XemAid9J/KyqCj7zL46/GbQ==}
+
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@@ -7425,6 +7431,8 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
+ identicons-esm@0.0.3: {}
+
ieee754@1.2.1: {}
ignore@5.3.2: {}
From 35eed39b38bcf6b9149e45386fcda14b0dd17556 Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 11:34:37 +0100
Subject: [PATCH 02/11] ui: added hint for identicon hash
---
.vitepress/theme/components/Identicon.vue | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/.vitepress/theme/components/Identicon.vue b/.vitepress/theme/components/Identicon.vue
index 1af7708..9ff5885 100644
--- a/.vitepress/theme/components/Identicon.vue
+++ b/.vitepress/theme/components/Identicon.vue
@@ -3,7 +3,8 @@ import { useLocalStorage } from '@vueuse/core'
import { createIdenticon } from 'identicons-esm'
import { ref, watch } from 'vue'
-const input = useLocalStorage('identicon', 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000')
+const initialValue = 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000'
+const input = useLocalStorage('identicon', initialValue)
const identicon = ref('')
watch(input, async () => {
@@ -14,8 +15,15 @@ watch(input, async () => {
-
From db948a5db25ca97734d1ead1e01b5fd0bfe63d77 Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 12:37:56 +0100
Subject: [PATCH 03/11] docs: improved identicons
---
.vitepress/theme/components/Identicon.vue | 10 +++
.../theme/components/IdenticonBuilder.vue | 80 +++++++++++++++++--
build/ui/identicons.md | 2 +-
package.json | 3 +-
pnpm-lock.yaml | 18 +++--
5 files changed, 99 insertions(+), 14 deletions(-)
diff --git a/.vitepress/theme/components/Identicon.vue b/.vitepress/theme/components/Identicon.vue
index 9ff5885..8ed1621 100644
--- a/.vitepress/theme/components/Identicon.vue
+++ b/.vitepress/theme/components/Identicon.vue
@@ -12,6 +12,13 @@ watch(input, async () => {
return
identicon.value = await createIdenticon(input.value, { format: 'image/svg+xml' })
}, { immediate: true })
+
+watch(input, async () => {
+ if (input.value === 'nimiq') {
+ const { default: confetti } = await import('canvas-confetti')
+ confetti({ particleCount: 300, spread: 360, origin: { y: 0.6 } })
+ }
+})
@@ -24,6 +31,9 @@ watch(input, async () => {
You can write anything!
+
+ You found a secret! Take a cookie 🍪
+
diff --git a/.vitepress/theme/components/IdenticonBuilder.vue b/.vitepress/theme/components/IdenticonBuilder.vue
index 6acb781..d911c54 100644
--- a/.vitepress/theme/components/IdenticonBuilder.vue
+++ b/.vitepress/theme/components/IdenticonBuilder.vue
@@ -1,8 +1,10 @@
-
+
+
+
+
+
+
+
+
+
+ Let's play a game!
+
+
+
+ Using the text input on top of this page, you need to find the secret word that creates the initial identicon. Good luck!
+
+
+
+ Reset identicon
+
+
+
+
+
+
+
+
+
+ Download
+
+ SVG
+
+
+ PNG
+
+
diff --git a/build/ui/identicons.md b/build/ui/identicons.md
index 3b6d6dc..fadf29d 100644
--- a/build/ui/identicons.md
+++ b/build/ui/identicons.md
@@ -15,7 +15,7 @@ A simple, visually recognizable way to verify addresses.{.nq-subline}
-## More than 9 Million Identicons!
+## More than 9 Million combintations!
Each Identicon is a unique combination of colors and shapes based on an account's hash, providing instant visual confirmation.
diff --git a/package.json b/package.json
index ea8af58..556fc3e 100644
--- a/package.json
+++ b/package.json
@@ -26,8 +26,9 @@
"@unhead/vue": "^1.11.10",
"@unocss/reset": "^0.63.6",
"@vueuse/core": "^11.1.0",
+ "canvas-confetti": "^1.9.3",
"iconify-icon": "^2.1.0",
- "identicons-esm": "^0.0.3",
+ "identicons-esm": "^0.0.6",
"json2md": "^2.0.1",
"jszip": "^3.10.1",
"markdown-it-mathjax3": "^4.3.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 08c2262..c549996 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -23,12 +23,15 @@ importers:
'@vueuse/core':
specifier: ^11.1.0
version: 11.1.0(vue@3.5.12(typescript@5.6.3))
+ canvas-confetti:
+ specifier: ^1.9.3
+ version: 1.9.3
iconify-icon:
specifier: ^2.1.0
version: 2.1.0
identicons-esm:
- specifier: ^0.0.3
- version: 0.0.3
+ specifier: ^0.0.6
+ version: 0.0.6
json2md:
specifier: ^2.0.1
version: 2.0.1
@@ -1688,6 +1691,9 @@ packages:
caniuse-lite@1.0.30001669:
resolution: {integrity: sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==}
+ canvas-confetti@1.9.3:
+ resolution: {integrity: sha512-rFfTURMvmVEX1gyXFgn5QMn81bYk70qa0HLzcIOSVEyl57n6o9ItHeBtUSWdvKAPY0xlvBHno4/v3QPrT83q9g==}
+
caseless@0.12.0:
resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}
@@ -2699,8 +2705,8 @@ packages:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
- identicons-esm@0.0.3:
- resolution: {integrity: sha512-/YlnqD6tM93r4+ZaU2dWz1zA996vuuL+QSKBBD9ST1JDvAKqmwlQt3yvEOKe6K4XemAid9J/KyqCj7zL46/GbQ==}
+ identicons-esm@0.0.6:
+ resolution: {integrity: sha512-dENh3JdQKm9wrKc1Ui4zBy4VHQY06MTBiqT+88H2+IRct149o6UKA43x58EU2obVhJZ70mTYkGrhtkprOmLEtg==}
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@@ -6228,6 +6234,8 @@ snapshots:
caniuse-lite@1.0.30001669: {}
+ canvas-confetti@1.9.3: {}
+
caseless@0.12.0: {}
ccount@2.0.1: {}
@@ -7431,7 +7439,7 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
- identicons-esm@0.0.3: {}
+ identicons-esm@0.0.6: {}
ieee754@1.2.1: {}
From d55c81edb421d87f4290bbd662e4607c2326b311 Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 12:42:17 +0100
Subject: [PATCH 04/11] chore: small but necessary comment
---
.vitepress/theme/components/Identicon.vue | 7 ++++++-
.vitepress/theme/components/IdenticonBuilder.vue | 4 ++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/.vitepress/theme/components/Identicon.vue b/.vitepress/theme/components/Identicon.vue
index 8ed1621..577766d 100644
--- a/.vitepress/theme/components/Identicon.vue
+++ b/.vitepress/theme/components/Identicon.vue
@@ -32,7 +32,12 @@ watch(input, async () => {
- You found a secret! Take a cookie 🍪
+ You found the secret word! Take a cookie 🍪
+
+
+ Nope. Keep trying.
+
+ Nonetheless, this identicon rocks 🤘
diff --git a/.vitepress/theme/components/IdenticonBuilder.vue b/.vitepress/theme/components/IdenticonBuilder.vue
index d911c54..983bc9e 100644
--- a/.vitepress/theme/components/IdenticonBuilder.vue
+++ b/.vitepress/theme/components/IdenticonBuilder.vue
@@ -132,11 +132,11 @@ async function downloadPng() {
- Using the text input on top of this page, you need to find the secret word that creates the initial identicon. Good luck!
+ Using the text input on top of this page, you need to find the secret word that creates the identicon.
- Reset identicon
+ See identicon
From 2964873a537a782776cbc103e3a4c23c1e5bc22d Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 12:48:38 +0100
Subject: [PATCH 05/11] chore: improved ux for gaem
---
.vitepress/theme/components/IdenticonBuilder.vue | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/.vitepress/theme/components/IdenticonBuilder.vue b/.vitepress/theme/components/IdenticonBuilder.vue
index 983bc9e..903b2c7 100644
--- a/.vitepress/theme/components/IdenticonBuilder.vue
+++ b/.vitepress/theme/components/IdenticonBuilder.vue
@@ -64,6 +64,16 @@ function reset() {
activeBackground.value = initialParams.value?.colors.background
}
+const isDirty = computed(() => {
+ return activeBottom.value !== initialParams.value?.sections.bottom
+ || activeTop.value !== initialParams.value?.sections.top
+ || activeFace.value !== initialParams.value?.sections.face
+ || activeSides.value !== initialParams.value?.sections.sides
+ || activeMain.value !== initialParams.value?.colors.main
+ || activeAccent.value !== initialParams.value?.colors.accent
+ || activeBackground.value !== initialParams.value?.colors.background
+})
+
const identicon = computed(() => ensambleSvg({ colors: colors.value, sections: sections.value }))
function getSvg(svgContent: string) {
@@ -135,7 +145,7 @@ async function downloadPng() {
Using the text input on top of this page, you need to find the secret word that creates the identicon.
-
+
See identicon
From 84703a5003af4dea61910fd1a789ae5ecea9f32d Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 15:23:00 +0100
Subject: [PATCH 06/11] docs: fix identicons link
---
build/ui/identicons.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/ui/identicons.md b/build/ui/identicons.md
index fadf29d..8d1452c 100644
--- a/build/ui/identicons.md
+++ b/build/ui/identicons.md
@@ -5,7 +5,7 @@
Blog Post
-
+
Source code
From 7ee5606372a0b66bf22fc911a16b0a3e23b05298 Mon Sep 17 00:00:00 2001
From: onmax
Date: Tue, 29 Oct 2024 15:30:16 +0100
Subject: [PATCH 07/11] fix: added py to input box
---
.vitepress/theme/components/Identicon.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.vitepress/theme/components/Identicon.vue b/.vitepress/theme/components/Identicon.vue
index 577766d..0529b3b 100644
--- a/.vitepress/theme/components/Identicon.vue
+++ b/.vitepress/theme/components/Identicon.vue
@@ -23,7 +23,7 @@ watch(input, async () => {
-
+
diff --git a/.vitepress/theme/components/IdenticonBuilder.vue b/.vitepress/theme/components/IdenticonBuilder.vue
index fda63d7..5d8f085 100644
--- a/.vitepress/theme/components/IdenticonBuilder.vue
+++ b/.vitepress/theme/components/IdenticonBuilder.vue
@@ -1,7 +1,7 @@
-
+
@@ -136,7 +128,7 @@ async function downloadPng() {
-
+
Let's play a game!
@@ -156,13 +148,10 @@ async function downloadPng() {
- Download
-
+ Download
+
SVG
-
- PNG
-