forked from edent/SuperTinyIcons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
44 lines (39 loc) · 1.94 KB
/
javascript.js
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
var items = [
'amazon', 'github', 'html5', 'mastodon', 'reddit', 'soundcloud',
'tox', 'wechat', 'youtube', 'dropbox', 'gitlab', 'instagram',
'paypal', 'rss', 'spotify', 'tumblr', 'whatsapp', 'email',
'google_plus','linkedin', 'pdf', 'skype', 'stackoverflow','twitter',
'wikipedia', 'facebook', 'google', 'lock', 'phone', 'slideshare',
'steam', 'vimeo', 'wire', 'flickr', 'hackernews', 'mail',
'pinterest', 'snapchat', 'telegram', 'vk', 'wordpress', 'meetup',
'line', 'lastpass', 'windows', 'digidentity','ubuntu', 'bitbucket',
'apple', 'npm', 'docker', 'symantec', 'yubico', 'keybase',
'ebay', 'evernote', 'kickstarter','yahoo', 'bitcoin', 'bluetooth',
'ibm', 'yammer', 'android', 'authy', 'blogger', 'cloudflare',
'codepen', 'digitalocean','discord', 'medium', 'airbnb', 'wifi',
'delicious', 'disqus', 'ghost', 'opensource', 'patreon', 'trello'
];
var container = document.querySelector('.icons');
var range = document.querySelector('input[type="range"]');
var number = document.querySelector('input.rangeout');
range.addEventListener('input', function(e){
number.value = parseInt(e.target.value);
render(e.target.value);
});
number.addEventListener('input', function(e){
range.value = parseInt(e.target.value);
render(e.target.value);
});
var urls = items.map(item => 'tiny/' + item + '.svg');
var icons;
Promise.all(urls.map(url => fetch(url).then(res => res.text()))).then(all => {
icons = all;
render(range.value);
});
var render = function(radius = 15){
console.log('Rendering!', icons);
icons = icons.map(icon => {
return icon.replace(/rx\=\"\d{0,2}\%/, 'rx="' + radius + '%"');
});
container.innerHTML = '<div>' + icons.join('</div><div>') + '</div>';
}