forked from Meldiron/almost-reddit-place
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1290 lines (1111 loc) · 50.6 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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Almost Reddit Place</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta
name="description"
content="Reddit r/place canvas clone made customizable, open-sourced and self-hosted."
/>
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="almost-reddit-place.vercel.app" />
<meta
property="twitter:url"
content="https://almost-reddit-place.vercel.app/"
/>
<meta name="twitter:title" content="Almost Reddit Place" />
<meta
name="twitter:description"
content="Reddit r/place canvas clone made customizable, open-sourced and self-hosted."
/>
<meta
name="twitter:image"
content="https://almost-reddit-place.vercel.app/cover.png"
/>
<meta property="og:title" content="Almost Reddit Place" />
<meta property="og:site_name" content="Almost Reddit Place" />
<meta property="og:url" content="https://almost-reddit-place.vercel.app/" />
<meta
property="og:description"
content="Reddit r/place canvas clone made customizable, open-sourced and self-hosted."
/>
<meta property="og:type" content="website" />
<meta
property="og:image"
content="https://almost-reddit-place.vercel.app/cover.png"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
<style>
body {
font-family: "Quicksand", sans-serif;
}
.custom-bg {
background-color: linear-gradient(180deg, #f02e65 0%, #c81b4c 100%);
background-image: url("/assets/bg.png");
background-position: center;
background-size: cover;
}
canvas {
image-rendering: pixelated;
image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/appwrite@7.0.0"></script>
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script src="//unpkg.com/alpinejs" defer></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"
integrity="sha512-NxocnqsXP3zm0Xb42zqVMvjQIktKEpTIbCXXyhBPxqGZHqhcOXHs4pXI/GoZ8lE+2NJONRifuBpi9DxC58L0Lw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script src="https://cdn.jsdelivr.net/gh/bgrins/TinyColor/dist/tinycolor-min.js"></script>
<script>
window.authModal = {
adapter: "appwrite",
config: {
endpoint: "https://appwrite.matejbaco.eu/v1",
projectId: "almostRedditPlaceV2",
},
// If using Uauth
oauths: [],
oauthSuccessUrl: window.location.origin + "/",
oauthErrorUrl: window.location.origin + "/",
// If using Magic URL
magicUrlRedirect: window.location.origin + "/",
// If supporting password recovery
passwordRecoveryRedirect: window.location.origin + "/",
};
</script>
<!-- Auth Modal -->
<script src="/auth-modal.js" defer></script>
<script>
// You can define variable here with configurations for the application
/*
var globalConfig = {
pixelsX: 10,
pixelsY: 10
}
*/
</script>
<script defer>
var globalConfig = globalConfig || {};
const appwrite = new Appwrite();
appwrite
.setEndpoint("https://appwrite.matejbaco.eu/v1")
.setProject("almostRedditPlaceV2");
function alpineSetup() {
return {
config: Object.assign(
{},
{
delaySeconds: 10,
pixelsX: 500,
pixelsY: 500,
colors: [
"#ff0000",
"#ff8700",
"#ffd300",
"#ffe5b4",
"#ffc0cb",
"#deff0a",
"#a1ff0a",
"#0aff99",
"#228B22",
"#0aefff",
"#147df5",
"#580aff",
"#be0aff",
"#ffffff",
"#000000",
"#654321",
"#808080",
],
},
globalConfig
),
state: {
showInfoAlert: false,
cooldown: null,
interval: null,
isColoring: false,
currentPixelData: null,
currentPixelShow: false,
touch: {
clientY: null,
clientX: null,
},
isReady: false,
debounce: null,
selectedColor: "#ff0000",
zoom: 1,
isDragging: false,
currentPixelPos: null,
lastTouch: null,
posX: 0,
posY: 0,
previousPixelColor: null,
previousPixelPosition: null,
pixels: {},
},
p5: null,
canvas: null,
sketch: null,
async onColorPixel() {
if (this.state.isColoring || this.state.currentPixelPos === null) {
return;
}
try {
this.state.isColoring = true;
const color = this.state.selectedColor;
const pixel = {
x: this.state.currentPixelPos[0],
y: this.state.currentPixelPos[1],
};
try {
await appwrite.account.get();
} catch (err) {
throw new Error("To place pixels, you must sign in.");
}
const res = await appwrite.functions.createExecution(
"colorPixel",
JSON.stringify({
x: pixel.x,
y: pixel.y,
hex: color,
}),
false
);
if (res.stderr) {
throw new Error(res.stderr);
}
const resJson = JSON.parse(
decodeURIComponent(escape(res.stdout))
);
if (!resJson.success && resJson.message) {
throw new Error(resJson.message);
}
if (resJson.skipDelay) {
this.state.cooldown = 0;
if (this.state.interval) {
clearInterval(this.state.interval);
}
} else {
this.state.cooldown = this.config.delaySeconds;
if (this.state.interval) {
clearInterval(this.state.interval);
}
this.state.interval = setInterval(() => {
this.state.cooldown--;
if (this.state.cooldown <= 0) {
if (this.state.interval) {
clearInterval(this.state.interval);
}
}
}, 1000);
}
} catch (err) {
console.error(err);
if (err.message === "Too many requests") {
err.message =
"You are too quick! You are not allowed to continue for a minute.";
}
alert(err.message);
} finally {
this.state.isColoring = false;
}
},
async fetchUsingStorage() {
documents = [];
const fileRes = await appwrite.storage.listFiles(
"pixels",
undefined,
1,
undefined,
undefined,
undefined,
"DESC"
);
const fileUrl = appwrite.storage.getFileDownload(
"pixels",
fileRes.files[0].$id
);
const jsonText = await (await fetch(fileUrl.href)).text();
const json = JSON.parse(jsonText.split("}]}")[0] + "}]}");
documents = json.docs;
let cursor = undefined;
hasNext = true;
do {
const response = await appwrite.database.listDocuments(
"pixelsPublic",
[
"x.lesserEqual(" + this.config.pixelsX + ")",
"x.greaterEqual(0)",
"y.lesserEqual(" + this.config.pixelsY + ")",
"y.greaterEqual(0)",
"createdAt.greater(" + json.syncAt + ")",
],
100,
undefined,
cursor,
"after"
);
documents.push(...response.documents);
if (response.documents.length > 0) {
cursor = response.documents[response.documents.length - 1].$id;
} else {
hasNext = false;
}
} while (hasNext);
return documents;
},
async fetchUsingDatabase() {
documents = [];
let cursor = undefined;
hasNext = true;
do {
const response = await appwrite.database.listDocuments(
"pixelsPublic",
[
"x.lesserEqual(" + this.config.pixelsX + ")",
"x.greaterEqual(0)",
"y.lesserEqual(" + this.config.pixelsY + ")",
"y.greaterEqual(0)",
],
100,
undefined,
cursor,
"after"
);
documents.push(...response.documents);
if (response.documents.length > 0) {
cursor = response.documents[response.documents.length - 1].$id;
} else {
hasNext = false;
}
} while (hasNext);
return documents;
},
async fetchPixels() {
documents = [];
try {
documents = await this.fetchUsingStorage();
} catch (err) {
console.error(err);
alert(err.message);
}
for (const document of documents) {
if (!this.state.pixels[document.$id]) {
if (document.hex === "ffffff") {
if (this.state.pixels[document.$id]) {
delete this.state.pixels[document.$id];
}
} else {
this.state.pixels[document.$id] = document;
}
}
}
this.render(true);
this.calculateCenter();
},
calculateCenter() {
const pixelSize = 1 * this.state.zoom;
const k = this.state.zoom * (500 / 2);
const left = -(this.state.posX - k);
const top = -(this.state.posY - k);
this.state.currentPixelPos = [
Math.floor(left / pixelSize),
Math.floor(top / pixelSize),
];
if (this.state.previousPixelPosition !== null) {
this.sketch.set(
this.state.previousPixelPosition[0],
this.state.previousPixelPosition[1],
this.state.previousPixelColor
);
this.sketch.updatePixels();
}
const currentPixelColor = this.sketch.get(
this.state.currentPixelPos[0],
this.state.currentPixelPos[1]
);
const tinyColor = tinycolor(
`rgb(${currentPixelColor[0]}, ${currentPixelColor[1]}, ${currentPixelColor[2]})`
);
let darkerPixelColorHex;
if (tinyColor.isLight()) {
darkerPixelColorHex = tinyColor.darken(35).toString();
} else {
darkerPixelColorHex = tinyColor.brighten(35).toString();
}
const clr = this.sketch.color(darkerPixelColorHex);
this.sketch.set(
this.state.currentPixelPos[0],
this.state.currentPixelPos[1],
clr
);
this.sketch.updatePixels();
this.state.previousPixelColor = currentPixelColor;
this.state.previousPixelPosition = this.state.currentPixelPos;
const currentCursorPixel =
this.state.pixels[
`${this.state.currentPixelPos[0]}_${this.state.currentPixelPos[1]}`
];
this.state.currentPixelShow = currentCursorPixel !== undefined;
this.state.currentPixelData =
currentCursorPixel === undefined
? this.state.currentPixelData
: currentCursorPixel;
},
onMouseDown(event) {
this.state.isDragging = true;
},
onMouseUp(event) {
this.state.isDragging = false;
},
onTouchStart(event) {
this.state.lastTouch = {
x: event.touches[0].screenX,
y: event.touches[0].screenY,
};
},
onTouchEnd(event) {
this.state.lastTouch = null;
},
onTouchMove(event) {
event.preventDefault();
event.stopPropagation();
if (!this.state.lastTouch) {
return;
}
const moveX = event.touches[0].screenX - this.state.lastTouch.x;
const moveY = event.touches[0].screenY - this.state.lastTouch.y;
this.state.posX += moveX;
this.state.posY += moveY;
this.calculateCenter();
this.state.lastTouch = {
x: event.touches[0].screenX,
y: event.touches[0].screenY,
};
},
onMouseMove(event) {
if (!this.state.isDragging) {
return;
}
const { movementY, movementX } = event;
this.state.posX += event.movementX;
this.state.posY += event.movementY;
this.calculateCenter();
},
onScroll(event) {
const originalDistance = this.state.zoom;
let scroll = -event.deltaY;
this.state.zoom += scroll / 200;
this.checkZoom(originalDistance);
event.preventDefault();
event.stopPropagation();
},
init() {
appwrite.subscribe(
["collections.pixelsPublic.documents"],
(event) => {
let d = Date.now();
let isAction = false;
let actionColor = null;
let actionPos = null;
if (
event.event === "database.documents.update" ||
event.event === "database.documents.create"
) {
if (event.payload.hex === "ffffff") {
if (this.state.pixels[event.payload.$id]) {
delete this.state.pixels[event.payload.$id];
isAction = true;
actionColor = "ffffff";
actionPos = event.payload.$id.split("_");
}
} else {
this.state.pixels[event.payload.$id] = event.payload;
isAction = true;
actionColor = event.payload.hex;
actionPos = event.payload.$id.split("_");
}
}
if (isAction) {
const pixelSize = 1 * this.state.zoom;
const k = this.state.zoom * (500 / 2);
const left = -(this.state.posX - k);
const top = -(this.state.posY - k);
const currentPos = [
Math.floor(left / pixelSize),
Math.floor(top / pixelSize),
];
if (
+actionPos[0] == currentPos[0] &&
+actionPos[1] === currentPos[1]
) {
this.state.previousPixelColor = this.sketch.color(
"#" + actionColor
);
this.calculateCenter();
}
const clr = this.sketch.color("#" + actionColor);
this.sketch.set(actionPos[0], actionPos[1], clr);
this.sketch.updatePixels();
}
}
);
setTimeout(() => {
const s = (sketch) => {
sketch.setup = () => {
var canvas = sketch.createCanvas(500, 500);
canvas.parent("appboard");
this.canvas = canvas;
this.sketch = sketch;
this.sketch.noStroke();
this.fetchPixels();
};
// DO NOT USE
sketch.draw = () => {};
sketch.keyPressed = (event) => {
if (
event.target.nodeName.toLowerCase() !== "canvas" &&
event.target.nodeName.toLowerCase() !== "body"
) {
return;
}
if (event.key === " ") {
this.onColorPixel();
return;
}
if (!isNaN(event.key)) {
const colorIndex = +event.key - 1;
this.state.selectedColor = this.config.colors[colorIndex];
return;
}
let moveX = 0;
let moveY = 0;
if (
event.key === "A" ||
event.key === "a" ||
event.key === "ArrowLeft"
) {
moveX = 1;
}
if (
event.key === "D" ||
event.key === "d" ||
event.key === "ArrowRight"
) {
moveX = -1;
}
if (
event.key === "W" ||
(event.key === "w") | (event.key === "ArrowUp")
) {
moveY = 1;
}
if (
event.key === "S" ||
event.key === "s" ||
event.key === "ArrowDown"
) {
moveY = -1;
}
if (event.shiftKey) {
moveX *= 3;
moveY *= 3;
}
this.state.posX += moveX * this.state.zoom;
this.state.posY += moveY * this.state.zoom;
this.calculateCenter();
};
};
this.p5 = new p5(s);
}, 1);
},
toggleInfo() {
this.state.showInfoAlert = !this.state.showInfoAlert;
},
goToCenter() {
this.state.posX = 0;
this.state.posY = 0;
this.calculateCenter();
},
exportScreenshot() {
const s = (sketch) => {
sketch.setup = () => {
const { pixels } = this.state;
const { pixelsX, pixelsY } = this.config;
const canvas = sketch.createCanvas(pixelsX, pixelsY);
sketch.pixelDensity(1);
const clrBackground = sketch.color("#ffffff");
for (let x = 0; x < pixelsX; x++) {
for (let y = 0; y < pixelsY; y++) {
sketch.set(x, y, clrBackground);
}
}
for (const pixel in pixels) {
const pixelData = pixels[pixel];
const clr = sketch.color("#" + pixelData.hex);
sketch.set(pixelData.x, pixelData.y, clr);
}
sketch.updatePixels();
sketch.saveCanvas(canvas, "myCanvas", "png");
};
};
const p5Screenshot = new p5(s);
},
zoomOut() {
const originalDistance = this.state.zoom;
this.state.zoom /= 1.5;
this.checkZoom(originalDistance);
},
zoomIn() {
const originalDistance = this.state.zoom;
this.state.zoom *= 1.5;
this.checkZoom(originalDistance);
},
checkZoom(originalZoom) {
if (this.state.zoom < 1) {
this.state.zoom = 1;
}
if (this.state.zoom > 100) {
this.state.zoom = 100;
}
const originalWidth = +document
.querySelector("#defaultCanvas0")
.style.width.split("px")[0];
const originalHeight = +document
.querySelector("#defaultCanvas0")
.style.height.split("px")[0];
const newWidth = 500 * this.state.zoom;
const newHeight = 500 * this.state.zoom;
document.querySelector("#defaultCanvas0").style.width =
newWidth + "px";
document.querySelector("#defaultCanvas0").style.height =
newHeight + "px";
const originalDistance = this.distanceFromCenter(
this.state.posX,
this.state.posY,
originalZoom
);
const newDistance = this.distanceFromCenter(
this.state.posX,
this.state.posY,
this.state.zoom
);
const diffX = originalDistance[0] - newDistance[0];
const diffY = originalDistance[1] - newDistance[1];
this.state.posX += diffX;
this.state.posY += diffY;
this.calculateCenter();
},
distanceFromCenter(x, y, zoom) {
const middleX = zoom * (500 / 2);
const middleY = zoom * (500 / 2);
const diffX = middleX - (x + 500 / 2) * zoom;
const diffY = middleY - (y + 500 / 2) * zoom;
return [diffX / this.state.zoom, diffY / this.state.zoom];
},
render(forced = false) {
const { pixelsX, pixelsY } = this.config;
if (!forced && !this.state.isReady) {
return;
}
this.state.isReady = true;
// this.sketch.pixelDensity(1);
const clrBackground = this.sketch.color("#ffffff");
for (let x = 0; x < pixelsX; x++) {
for (let y = 0; y < pixelsY; y++) {
this.sketch.set(x, y, clrBackground);
}
}
this.renderPixels();
this.sketch.updatePixels();
},
printDate(date) {
if (!date) {
return "No date";
}
const d = new Date(date);
const min =
d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
const hour = d.getHours() < 10 ? "0" + d.getHours() : d.getHours();
const day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
let m = d.getMonth() + 1;
const month = m < 10 ? "0" + m : m;
return `${day}.${month} at ${hour}:${min}`;
},
renderPixels() {
const { pixels } = this.state;
for (const pixel in pixels) {
const pixelData = pixels[pixel];
const clr = this.sketch.color("#" + pixelData.hex);
this.sketch.set(pixelData.x, pixelData.y, clr);
}
},
};
}
const app = alpineSetup();
</script>
</head>
<body>
<div x-data="app">
<div class="fixed inset-0 bg-primary custom-bg z-[5]"></div>
<div class="relative z-10 flex flex-col min-h-screen px-3 min-w-screen">
<div
class="absolute bottom-0 left-0 w-full h-20 bg-gradient-to-t from-black to-primary opacity-10"
></div>
<img
class="absolute z-10 hidden left-10 bottom-10 sm:block"
src="/assets/dots-bl.svg"
alt=""
/>
<img
class="absolute z-10 hidden right-10 top-10 sm:block"
src="/assets/dots-tr.svg"
alt=""
/>
<div
class="relative z-20 flex flex-col items-center justify-center h-[100vh] py-10"
>
<div
class="flex-shrink-0 flex items-center mb-2 justify-center space-x-3"
>
<h1 class="text-white font-bold text-3xl text-center">
Almost Reddit Place
</h1>
<template hidden x-if="!state.isReady">
<svg
class="w-6 h-6 animate-spin text-white"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
></circle>
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>
</template>
</div>
<template hidden x-if="!state.isReady">
<p
class="flex-shrink-0 mt-2 text-white font-bold text-lg text-center"
>
From time to time, we need to load a big file. Please be patient
if load takes up to a minute.
</p>
</template>
<div
class="h-full mt-4 touch-manipulation container bg-white rounded-xl overflow-hidden relative"
>
<div
x-show="state.currentPixelShow"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 scale-90"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-300"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-90"
class="pointer-events-none absolute -space-y-1 flex-col z-10 bottom-4 left-0 w-full flex items-center justify-center"
>
<div
x-text="state.currentPixelData ? printDate(state.currentPixelData.createdAt) : ''"
class="p-1 px-2 text-xs text-slate-200 bg-slate-500 rounded-lg"
></div>
<div
x-text="state.currentPixelData ? state.currentPixelData.userId : ''"
class="p-2 text-sm text-slate-500 bg-slate-900 rounded-lg"
></div>
</div>
<div class="relative h-full overflow-hidden bg-[#e2e8f0]">
<div class="z-10 absolute top-4 left-4 flex flex-col space-y-4">
<button
x-on:click="toggleInfo()"
class="p-3 rounded-full bg-red-100 text-red-600 hover:bg-red-200"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
clip-rule="evenodd"
/>
</svg>
</button>
<button
x-on:click="goToCenter()"
class="p-3 rounded-full bg-red-100 text-red-600 hover:bg-red-200"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z"
clip-rule="evenodd"
/>
</svg>
</button>
</div>
<div class="z-10 absolute top-4 right-4 flex flex-col space-y-4">
<button
x-on:click="zoomIn()"
class="p-3 rounded-full bg-red-100 text-red-600 hover:bg-red-200"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"
/>
</svg>
</button>
<button
x-on:click="zoomOut()"
class="p-3 rounded-full bg-red-100 text-red-600 hover:bg-red-200"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM13 10H7"
/>
</svg>
</button>
</div>
<div
x-on:wheel="onScroll($event)"
x-on:mousedown="onMouseDown($event)"
x-on:mouseup="onMouseUp($event)"
x-on:mousemove="onMouseMove($event)"
x-on:touchmove="onTouchMove($event)"
x-on:touchend="onTouchEnd($event)"
x-on:touchcancel="onTouchEnd($event)"
x-on:touchstart="onTouchStart($event)"
class="w-full h-full flex items-center justify-center"
>
<div
class="w-full h-full flex items-center justify-center"
id="appboard"
x-bind:style="'transform: translate(' + state.posX + 'px, ' + state.posY + 'px)'"
></div>
</div>
</div>
</div>