-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcatalog.html
102 lines (89 loc) · 2.58 KB
/
catalog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Nimiq Identicon Catalog</title>
</head>
<link href="./demo.css" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Muli:400,700">
<style type="text/css">
body {
padding: 32px;
max-width: 960px;
margin: 0 auto;
font-family: 'Muli', system-ui, sans-serif;
}
h1 {
font-weight: 400;
font-size: 48px;
}
h2 {
font-size: 32px;
margin-top: 64px;
}
.identicon {
display: inline-block;
margin: 16px 8px;
}
.identicon svg {
width: 160px;
height: 160px;
display: block;
margin: 8px;
/*filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.5));*/
margin-bottom: 0;
}
</style>
<body>
<h1>Nimiq Identicons Catalog</h1>
<div id="top">
<h2>Tops</h2>
</div>
<div id="face">
<h2>Faces</h2>
</div>
<div id="side">
<h2>Sides</h2>
</div>
<div id="bottom">
<h2>Bottoms</h2>
</div>
</body>
<script type="module">
window.NIMIQ_IDENTICONS_SVG_PATH = location.pathname.replace(/[^/]*$/, 'dist/identicons.min.svg');
import Identicons from './src/js/identicons.js';
import { WordCatalog } from './src/js/word-catalog.js';
// import Identicons, { WordCatalog } from './dist/identicons.bundle.min.js';
async function render(type) {
const count = Identicons.ASSET_COUNTS[type];
const $el = document.getElementById(type);
for (var i = 0; i < count; i++) {
const name = getName(type, i);
const $identicon = renderIdenticon(await renderFns[type](i), name);
$el.appendChild($identicon)
}
}
function getName(type, index) {
let name = WordCatalog[type][index][WordCatalog.NOUN0].replace(/_/, '-');
if (name.indexOf('z_todo ') > -1) name = 'todo: ' + name.replace('z_todo ', '');
if (name.indexOf('z_') > -1) name = '(' + name.replace('z_', '') + ')';
return name;
}
const renderFns = {
face: async index => await Identicons._svgTemplate(0, 3, index, -1, -1, -1, 6),
top: async index => await Identicons._svgTemplate(0, 3, -1, index, -1, -1, 6),
side: async index => await Identicons._svgTemplate(0, 3, -1, -1, index, -1, 6),
bottom: async index => await Identicons._svgTemplate(0, 3, -1, -1, -1, index, 6),
}
function renderIdenticon(svg, name) {
const $identicon = document.createElement('div');
$identicon.innerHTML = svg + `<span>${name}</span>`;
$identicon.className = 'identicon'
return $identicon;
}
render('face')
render('top')
render('side')
render('bottom')
</script>
</html>