Skip to content

Commit 6dffdde

Browse files
committed
docs: mention emoji reactions
1 parent 2e05ae7 commit 6dffdde

File tree

4 files changed

+27
-100
lines changed

4 files changed

+27
-100
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ We give you a shareable URL and we'll randomly pick your side; the next person g
88

99
Anyone else who opens the link is a spectator.
1010

11+
Players can react with any emoji using the built-in emoji picker.
12+
1113
## Links
1214

1315
- Production: https://tinychess.bitchimfabulo.us

internal/handlers/handlers.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ func (h *Handler) HandleReact(w http.ResponseWriter, r *http.Request) {
191191
return
192192
}
193193

194-
if !isAllowedEmoji(body.Emoji) {
195-
WriteJSON(w, http.StatusOK, map[string]any{"ok": false, "error": "unsupported emoji"})
196-
return
197-
}
198-
199194
canReact, wait := g.CanReact(body.Sender)
200195
if !canReact {
201196
WriteJSON(w, http.StatusOK, map[string]any{"ok": false, "error": fmt.Sprintf("cooldown %ds", wait)})

internal/handlers/middleware.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,3 @@ func parseSquare(s string) chess.Square {
6161
}
6262
return chess.Square(rank*8 + file)
6363
}
64-
65-
// isAllowedEmoji checks if an emoji is in the allowed list
66-
func isAllowedEmoji(emoji string) bool {
67-
allowed := map[string]struct{}{
68-
"👍": {}, "👎": {}, "❤️": {}, "😠": {}, "😢": {}, "🎉": {}, "👏": {},
69-
"😂": {}, "🤣": {}, "😎": {}, "🤔": {}, "😏": {}, "🙃": {}, "😴": {}, "🫡": {}, "🤯": {}, "🤡": {},
70-
"♟️": {}, "♞": {}, "♝": {}, "♜": {}, "♛": {}, "♚": {}, "⏱️": {}, "🏳️": {}, "🔄": {}, "🏆": {},
71-
"🔥": {}, "💀": {}, "🩸": {}, "⚡": {}, "🚀": {}, "🕳️": {}, "🎯": {}, "💥": {}, "🧠": {},
72-
"🍿": {}, "☕": {}, "🐢": {}, "🐇": {}, "🤝": {}, "🤬": {},
73-
"🪦": {}, "🐌": {}, "🎭": {}, "🐙": {}, "🦄": {}, "🐒": {},
74-
}
75-
_, ok := allowed[emoji]
76-
return ok
77-
}

internal/templates/game.html

Lines changed: 25 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@
7979
}
8080

8181
.wrap {
82-
max-width: 1000px;
82+
max-width: 640px;
8383
margin: 0 auto;
8484
padding: 16px;
85-
display: grid;
86-
grid-template-columns: 1fr 320px;
85+
display: flex;
86+
flex-direction: column;
87+
align-items: center;
8788
gap: 16px;
8889
}
8990

@@ -172,6 +173,7 @@
172173
border: 1px solid #2a3345;
173174
border-radius: 12px;
174175
padding: 12px;
176+
width: 100%;
175177
}
176178

177179
.btn {
@@ -278,12 +280,6 @@
278280
border-radius: 4px;
279281
}
280282

281-
.reactions {
282-
display: flex;
283-
gap: 6px;
284-
flex-wrap: wrap;
285-
}
286-
287283
.react {
288284
font-size: 18px;
289285
background: transparent;
@@ -350,11 +346,6 @@
350346
}
351347
}
352348

353-
@media (max-width: 860px) {
354-
.wrap {
355-
grid-template-columns: 1fr;
356-
}
357-
}
358349
</style>
359350
</head>
360351

@@ -409,7 +400,6 @@
409400
</header>
410401

411402
<div class="wrap">
412-
<div class="board" id="board" aria-label="Chess board"></div>
413403
<div class="panel">
414404
<div class="row">
415405
<strong>Game:</strong> <span id="gameid" class="mono"></span>
@@ -429,7 +419,7 @@
429419

430420
<div class="rx" id="rx"></div>
431421
<div class="row">
432-
<div class="reactions" id="reactbar" aria-label="Reactions"></div>
422+
<button class="react" id="reactbtn" title="Send reaction">😀</button>
433423
</div>
434424
<p style="margin-top: 10px; opacity: 0.8">
435425
Tip: Click one square, then another to move. Promotions auto-queen.
@@ -443,7 +433,11 @@
443433
<pre id="pgn" style="white-space: pre-wrap"></pre>
444434
</details>
445435
</div>
436+
<div class="board" id="board" aria-label="Chess board"></div>
446437
</div>
438+
<dialog id="emojiDialog">
439+
<emoji-picker id="emojiPicker"></emoji-picker>
440+
</dialog>
447441
<footer>
448442
Built with Go & vanilla JS — with ❤️ by Dusty and his traumatized 🤖
449443
<div class="version">
@@ -462,6 +456,10 @@
462456
data-domain="tinychess.bitchimfabulo.us"
463457
src="https://plausible.io/js/script.outbound-links.js"
464458
></script>
459+
<script
460+
type="module"
461+
src="https://cdn.jsdelivr.net/npm/emoji-picker-element@^1/index.js"
462+
></script>
465463
<script>
466464
(function () {
467465
const START_FEN =
@@ -486,7 +484,9 @@
486484
const capWhiteEl = document.getElementById("cap_by_white");
487485
const capBlackEl = document.getElementById("cap_by_black");
488486
const rxEl = document.getElementById("rx");
489-
const reactBar = document.getElementById("reactbar");
487+
const reactBtn = document.getElementById("reactbtn");
488+
const emojiDialog = document.getElementById("emojiDialog");
489+
const emojiPicker = document.getElementById("emojiPicker");
490490
gameIdEl.textContent = gameId || "(none)";
491491

492492
// Orientation (default white; updated from server message)
@@ -562,70 +562,15 @@
562562
let lastMoveSquares = []; // [from, to]
563563

564564
// Reactions
565-
const EMOJIS = [
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-
];
615565
const COOLDOWN_MS = 5000;
616566
let lastReact = 0;
617-
function buildReactBar() {
618-
if (!reactBar) return;
619-
reactBar.innerHTML = "";
620-
EMOJIS.forEach(function (e) {
621-
var b = document.createElement("button");
622-
b.className = "react";
623-
b.textContent = e;
624-
b.title = "Send reaction";
625-
b.addEventListener("click", function () {
626-
sendReaction(e, b);
627-
});
628-
reactBar.appendChild(b);
567+
if (reactBtn && emojiDialog && emojiPicker) {
568+
reactBtn.addEventListener("click", function () {
569+
emojiDialog.showModal();
570+
});
571+
emojiPicker.addEventListener("emoji-click", function (ev) {
572+
emojiDialog.close();
573+
sendReaction(ev.detail.unicode, reactBtn);
629574
});
630575
}
631576

@@ -637,7 +582,7 @@
637582
document.body.appendChild(big);
638583
setTimeout(() => big.remove(), 1200);
639584

640-
// Small burst under reactions bar
585+
// Small burst under reactions area
641586
if (rxEl) {
642587
const small = document.createElement("span");
643588
small.textContent = e;
@@ -693,7 +638,6 @@
693638
}
694639
}
695640

696-
buildReactBar();
697641

698642
// --- board helpers ---
699643
function cellSquare(row, col) {

0 commit comments

Comments
 (0)