-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-html-preview.sh
executable file
·235 lines (179 loc) · 4.57 KB
/
build-html-preview.sh
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash
echo "░▒▓ BOXIE - ICONSET ▓▒░" ;
echo "▓▒░ BUILDING HTML PREVIEW... " ;
WORK_DIR=$(pwd) ;
RESIZE_TO="128x128"
OUTPUT_DIR_NAME="preview-html"
LOGO_SVG=$WORK_DIR"/about-logo.svg"
#DELETE OUTPUT DIR IF EXISTS
if [ -d "$OUTPUT_DIR_NAME" ] ; then
rm -Rf $OUTPUT_DIR_NAME ;
fi
#MAKE OUTPUT DIR
if [ ! -d $OUTPUT_DIR_NAME ] ; then
mkdir $WORK_DIR"/"$OUTPUT_DIR_NAME ;
mkdir $WORK_DIR"/"$OUTPUT_DIR_NAME"/icons" ;
fi
#CREATE JS ICON DATA
OUTPUT_DATA_JS=$WORK_DIR"/"$OUTPUT_DIR_NAME"/data.js"
echo "const iconData = [" > "$OUTPUT_DATA_JS" ;
for f in ./src/*; do
if [ -d "$f" ]; then
. $f"/icon.conf" ; #import $name , $path
echo "{"group":""\"$path\"",name":""\"$name\"""}," >> "$OUTPUT_DATA_JS";
fi
done
echo "]" >> "$OUTPUT_DATA_JS" ;
#CREATE PNGS
for f in ./src/*; do
if [ -d "$f" ]; then
BASENAME=$(basename $f) ;
FILE0=$f"/0.svg" ;
FILE1=$f"/1.svg" ;
. $f"/icon.conf" ;
TARGET_PATH="$WORK_DIR""/""$OUTPUT_DIR_NAME""/icons""$path"
TARGET_FULL_PATH=$TARGET_PATH"/""$name"".png"
echo $TARGET_FULL_PATH ;
if [ ! -d $TARGET_PATH ] ; then
mkdir $TARGET_PATH ;
fi
convert -resize $RESIZE_TO -channel rgba -background "rgba(0,0,0,0)" $f"/0.svg" $f"/0.png" ;
convert $f"/0.png" -gravity 'northwest' -background 'rgba(255,255,255,0)' \( +clone -background '#005f005f005f0000' -shadow "80x3-1-1" \) +swap -background none -mosaic +repage $f"/0.png" ;
mv $f"/0.png" $TARGET_FULL_PATH ;
echo "created " $TARGET_FULL_PATH ;
fi
done
echo "Making preview html file..."
echo "<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style>
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap');
body{
background: #c1c1c1;
}
.accordion {
background-color: #ccc;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
border: 1px solid darkgray;
}
.active, .accordion:hover {
background-color: lightsteelblue;
}
.panel {
padding: 18px;
display: none;
background-color: #ccc;
overflow: hidden;
border: 1px solid darkgray;
}
*{
font-family: 'Rajdhani', sans-serif;
font-weight:600;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
grid-gap: 1rem;
color: #333;
}
.grid > div {
padding: 1rem;
display: grid;
place-items: center;
transition: all 1s ease;
}
.grid > div:hover {
padding: 1rem;
display: grid;
place-items: center;
background: #ffa997;
border-radius: 8px;
}
.grid > div::before {
padding-bottom: 100%;
grid-area: 1/1/2/2;
}
.grid > div svg {
}
.shadow-outline{
box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
}
</style>
</head>
<body>
<h1>Boxie Iconset</h1>
<div class='shadow-outline main-container'>
</div>
</body>
</html>
<script src='data.js'></script>
<script>
const createIcon = (group, name) => {
let imgUrl = './icons' + group + '/' + name + '.png' ;
return \`
<div>
<img src='\${imgUrl}' />
\${name}
</div>
\`;
}
const createIconGroup = (name, data) => {
let generatedData = '';
for (let i=0; i<data.length; i++){
generatedData += createIcon(name, data[i]);
}
return \`
<button class='accordion'><b>\${name}</b></button>
<div class='panel'>
<div class='grid'>
\${generatedData}
</div>
</div>
\`;
}
const addIconsToGrid = () => {
let container = document.querySelector('.main-container');
let item = createIcon('alphagr', 'beta');
let groupData = [];
for (let i=0; i<iconData.length; i++){
if (iconData[i].group in groupData){
groupData[iconData[i].group].push(iconData[i].name);
}
else{
groupData[iconData[i].group] = [];
groupData[iconData[i].group].push(iconData[i].name);
}
}
for (const p in groupData) {
container.innerHTML += createIconGroup(p, groupData[p]);
}
}
addIconsToGrid();
window.addEventListener('load', function() {
var acc = document.getElementsByClassName('accordion');
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener('click', function() {
this.classList.toggle('active');
var panel = this.nextElementSibling;
if (panel.style.display === 'block') {
panel.style.display = 'none';
} else {
panel.style.display = 'block';
}
});
}
})
</script> " > $WORK_DIR"/"$OUTPUT_DIR_NAME"/preview.html" ;
date +%s > ./.lastbuild ;
echo "▓▒░ FINISHED BUILDING HTML PREVIEW... " ;