-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
372 lines (330 loc) · 8.85 KB
/
index.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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Brat Generator, but it's better</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:creator" content="@yolko0no" />
<meta name="twitter:title" content="brat generator by yolk" />
<meta
name="twitter:image"
content="https://brat.yolko0no.com/yolk.png"
/>
<meta name="description" content="it's like a better version of the official brat generator.">
<meta name="twitter:image:alt" content="yolk" />
<link rel="stylesheet" href="style.css" />
<link rel="canonical" href="https://brat.yolko0no.com/" />
<!-- Fathom - beautiful, simple website analytics -->
<script
src="https://cdn.usefathom.com/script.js"
data-site="ILBPHJZV"
defer
></script>
<!-- / Fathom -->
<style>
:root {
--color-primary: #8acf00;
--color-secondary: #000;
--text-align: left;
--color-next: #fff;
--color-next-secondary: #000;
--color-primary-custom: #fff;
--color-secondary-custom: #000000;
}
</style>
</head>
<body class="tarb preset">
<div class="buttons">
<fieldset class="custom-picker">
<input
type="checkbox"
class="open-color"
id="open-color"
/>
<span class="indicator"></span>
</fieldset>
<fieldset class="preset-picker">
<input
type="button"
name="color"
id="switch"
onclick="fathom.trackEvent('switch');"
/>
<span class="indicator"></span>
</fieldset>
</div>
<div class="color-customizer">
<label for="open-color" class="close-menu" aria-details="close menu">X</label>
<fieldset class="color-field">
<input
type="color"
name="--color-primary"
id="--color-primary"
class="color-p"
value="#FFFFFF"
/>
<label for="--color-primary">Background Color</label>
</fieldset>
<fieldset class="color-field">
<input
type="color"
name="--color-secondary"
id="--color-secondary"
class="color-s"
value="#000"
/>
<label for="--color-secondary">Text Color</label>
</fieldset>
<fieldset class="text-align">
<input
type="radio"
id="left"
class="left-button"
value="left"
name="--text-align"
/>
<label for="left">Left</label>
<input
type="radio"
id="center"
class="center-button"
value="center"
name="--text-align"
/>
<label for="center">Center</label>
<input
type="radio"
id="right"
class="right-button"
value="right"
name="--text-align"
/>
<label for="right">Right</label>
<input
type="radio"
id="justify"
class="justify-button"
value="justify"
name="--text-align"
/>
<label for="justify">Justify</label>
</fieldset>
</div>
<input type="file" onclick="fathom.trackEvent('upload');" />
<fieldset class="options">
<input type="checkbox" name="green" id="green" />
<label for="green"> make it remixed </label>
</fieldset>
<div class="image filter">
<img class="output" />
<div class="greenfilter"></div>
<div class="text-output">
<span class="text" contenteditable="true" spellcheck="false">
yolk but it's not the same
</span>
</div>
</div>
<script type="text/javascript">
const list = [
{
id: "tarb",
checkbox: "make it green",
text: "yolk but it's not the same",
primary: "#8acf00",
secondary: "#000",
align: "left",
class: "preset"
},
{
id: "deluxe",
checkbox: "make it grayscale",
text: "yolk and it's the same but there's three more code so it's not",
primary: "#FFF",
secondary: "#000",
align: "justify",
class: "preset"
},
{
id: "brat",
checkbox: "make it green",
text: "yolk",
primary: "#8acf00",
secondary: "#000",
align: "center",
class: "preset"
},
{
id: "remix",
checkbox: "make it remixed",
text: "yolk, the remix",
primary: "yellow",
secondary: "#000",
align: "left",
class: "preset"
},
];
const fileInput = document.querySelector("input[type=file]");
const output = document.querySelector(".output");
const greenify = document.querySelector("input#green");
const greenfilter = document.querySelector(".filter");
const colorswitch = document.querySelector("input#switch");
const textblock = document.querySelector(".text");
let i = 0;
let nextItem;
document.querySelector("#open-color").addEventListener("change", async() => {
document.querySelector(".color-customizer").classList.toggle("open");
})
colorswitch.addEventListener("click", async () => {
document.querySelector(".color-customizer").classList.remove("open");
if (i == list.length - 1) {
i = 0;
} else {
i++;
}
if (i >= 0 && i < list.length - 1) {
nextItem = list[i + 1];
} else {
nextItem = list[0];
}
var bodyClass = list[i].id + " " + list[i].class + " next-" + nextItem.id;
document.body.classList = bodyClass;
if (!textblock.classList.contains("changed")) {
textblock.innerHTML = list[i].text;
}
document.documentElement.style.setProperty(
"--color-primary",
list[i].primary
);
document.documentElement.style.setProperty(
"--color-secondary",
list[i].secondary
);
document.documentElement.style.setProperty(
"--color-next",
nextItem.primary
);
document.documentElement.style.setProperty(
"--color-next-secondary",
nextItem.secondary
);
document.documentElement.style.setProperty(
"--text-align",
list[i].align
);
document.querySelector("label[for=green]").innerHTML =
list[i].checkbox;
resizeText({
elements: document.querySelectorAll(".text"),
});
});
greenify.addEventListener("change", async () => {
greenfilter.classList.toggle("visible");
});
fileInput.addEventListener("change", async () => {
const [file] = fileInput.files;
URL.revokeObjectURL(output.src);
if (file) {
output.src = URL.createObjectURL(file);
}
});
</script>
<script>
// custom color pickers
const pickers = document.querySelector(".color-customizer");
const customs = document.querySelectorAll(".color-customizer input");
pickers.addEventListener("change", async () => {
document.body.classList = "custom";
if (!textblock.classList.contains("changed")) {
textblock.innerHTML = "custom yolk";
}
document.querySelector("label[for=green]").innerHTML = "color it"
customs.forEach(e => {
if(e.type != "radio" || e.checked == true) {
document.documentElement.style.setProperty(
e.name,
e.value
);
}
if(e.type == "color") {
document.documentElement.style.setProperty(
e.name + "-custom",
e.value
);
}
});
resizeText({
elements: document.querySelectorAll(".text"),
});
})
</script>
<script>
const isOverflown = ({ clientHeight, scrollHeight }) =>
scrollHeight > clientHeight;
const resizeText = ({
element,
elements,
minSize = 0,
maxSize = 15,
step = 0.01,
unit = "vw",
}) => {
(elements || [element]).forEach((el) => {
let i = minSize;
let overflow = false;
const parent = el.parentNode;
while (!overflow && i < maxSize) {
el.style.fontSize = `${i}${unit}`;
overflow = isOverflown(parent);
if (!overflow) i += step;
}
// revert to last state where no overflow happened
el.style.fontSize = `${i - step}${unit}`;
});
};
resizeText({
elements: document.querySelectorAll(".text"),
});
</script>
<script>
function debounce(func) {
var timer;
return function (event) {
if (timer) clearTimeout(timer);
timer = setTimeout(func, 200, event);
};
}
document
.querySelector(".text")
.addEventListener("blur", function (e) {
document
.querySelector("span.text")
.classList.toggle("changed", true);
let type = document.body.classList;
resizeText({
elements: document.querySelectorAll(".text"),
});
fathom.trackEvent(`text created for ${type}`);
});
window.addEventListener(
"resize",
debounce(function (e) {
resizeText({
elements: document.querySelectorAll(".text"),
});
})
);
</script>
<script>
document
.querySelector("span[contenteditable]")
.addEventListener("paste", function (e) {
e.preventDefault();
var text = e.clipboardData.getData("text/plain");
document.execCommand("insertHTML", false, text);
});
</script>
</body>
</html>