forked from MrRedBeard/svgtofont
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ejs
180 lines (171 loc) · 4.44 KB
/
index.ejs
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%=_title%></title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<%if (meta && Object.keys(meta).length > 0) { Object.keys(meta).forEach((metaName) => { %>
<meta name="<%=metaName%>" content="<%=meta[metaName]%>">
<%})}%>
<%if(favicon) {%>
<link rel="icon" type="image/x-icon" href="<%-favicon%>">
<%}%>
<%if(_type === 'font-class' && _link) {%>
<link rel="stylesheet" href="<%=_link%>" />
<%}%>
<style>
.icons ul li.class-icon [class^="<%=classNamePrefix%>-"]{ font-size: 26px; }
html, body
{
line-height: 100%;
height: 100%;
margin: 0;
padding: .5rem;
}
.hidden
{
display: none;
}
.fonts
{
margin: 0;
padding: 0;
justify-content: space-between;
}
.fonts .search
{
width: 100%;
margin-bottom: .5rem;
}
.fonts .search label
{
color: #878787;
}
.fonts .search input
{
height: 1.5rem;
padding: .1rem;
padding-left: .2rem;
padding-right: .2rem;
border-radius: 3%;
border: 1px solid #878787;
}
.fonts .search button
{
cursor: pointer;
border: 1px solid #878787;
height: 1.5rem;
font-weight: bold;
}
.fonts ul
{
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
}
.fonts ul li
{
margin: 0;
padding: .5rem;
text-align: center;
border: 1px solid #878787;
width: 10rem;
}
.fonts ul li i
{
display: block;
}
</style>
</head>
<body>
<div class="header">
<h1><%=_title%><sup><%-version%></sup></h1>
<div class="info">
<%-description || (meta && meta.description)%>
<br /><br />
<span class="count"></span>
</div>
<p>
<%if(links && links.length > 0) { links.forEach((linkItem, index) => {%>
<a href="<%-linkItem.url%>"><%-linkItem.title%></a><%if(links.length-1 !== index){%> · <%}%>
<%})}%>
</p>
<p>
Generated with <a href="https://github.com/Kitchen-JS/svgtofont">https://github.com/Kitchen-JS/svgtofont</a><br />
Based on <a href="https://github.com/jaywcjlove/svgtofont">https://github.com/jaywcjlove/svgtofont</a>
</p>
</div>
<div class="fonts">
<div class="search">
<label>Search Icons: </label>
<input type="text" placeholder="Search Icons...">
<button>X</button>
</div>
<ul>
</ul>
</div>
</body>
<script src="<%=classNamePrefix%>.js"></script>
<script>
let fontsEl = document.querySelector('.fonts');
let keys = Object.keys(<%=classNamePrefix%>);
// Number of icons
document.querySelector('.count').innerHTML = `${keys.length} total icons`;
// List icons stored in pfi.js
keys.forEach((icon) =>
{
if(typeof <%=classNamePrefix%>[icon] === 'function')
{
return;
}
let li = document.createElement('li');
let i = document.createElement('i');
i.classList.add(icon);
li.append(i);
li.setAttribute('value', icon);
let p = document.createElement('p');
p.innerHTML = `${icon} <br /><br />`;
p.innerHTML += `<br /> <i class="${icon}"></i>`;
li.append(p);
let p2 = document.createElement('p');
p2.innerHTML = `&${<%=classNamePrefix%>[icon].htmlcode}`;
li.append(p2);
fontsEl.querySelector('ul').append(li);
});
// Search icons
let search = document.querySelector('.search input');
search.focus();
let searchFunc = () =>
{
let searchVal = search.value.toString().trim();
let iconsArr = fontsEl.querySelectorAll('ul li');
iconsArr.forEach((icon) =>
{
let val = icon.getAttribute('value').trim();
if(!searchVal || searchVal === '' || searchVal.length <= 0)
{
icon.classList.remove('hidden');
}
else if(val.indexOf(searchVal) > -1)
{
icon.classList.remove('hidden');
}
else
{
icon.classList.add('hidden');
}
});
};
search.addEventListener('keyup', () =>
{
searchFunc();
});
document.querySelector('.search button').addEventListener('click', () =>
{
search.value = '';
searchFunc();
});
</script>
</html>