|
79 | 79 | } |
80 | 80 |
|
81 | 81 | .wrap { |
82 | | - max-width: 1000px; |
| 82 | + max-width: 640px; |
83 | 83 | margin: 0 auto; |
84 | 84 | padding: 16px; |
85 | | - display: grid; |
86 | | - grid-template-columns: 1fr 320px; |
| 85 | + display: flex; |
| 86 | + flex-direction: column; |
| 87 | + align-items: center; |
87 | 88 | gap: 16px; |
88 | 89 | } |
89 | 90 |
|
|
172 | 173 | border: 1px solid #2a3345; |
173 | 174 | border-radius: 12px; |
174 | 175 | padding: 12px; |
| 176 | + width: 100%; |
175 | 177 | } |
176 | 178 |
|
177 | 179 | .btn { |
|
278 | 280 | border-radius: 4px; |
279 | 281 | } |
280 | 282 |
|
281 | | - .reactions { |
282 | | - display: flex; |
283 | | - gap: 6px; |
284 | | - flex-wrap: wrap; |
285 | | - } |
286 | | - |
287 | 283 | .react { |
288 | 284 | font-size: 18px; |
289 | 285 | background: transparent; |
|
350 | 346 | } |
351 | 347 | } |
352 | 348 |
|
353 | | - @media (max-width: 860px) { |
354 | | - .wrap { |
355 | | - grid-template-columns: 1fr; |
356 | | - } |
357 | | - } |
358 | 349 | </style> |
359 | 350 | </head> |
360 | 351 |
|
|
409 | 400 | </header> |
410 | 401 |
|
411 | 402 | <div class="wrap"> |
412 | | - <div class="board" id="board" aria-label="Chess board"></div> |
413 | 403 | <div class="panel"> |
414 | 404 | <div class="row"> |
415 | 405 | <strong>Game:</strong> <span id="gameid" class="mono"></span> |
|
429 | 419 |
|
430 | 420 | <div class="rx" id="rx"></div> |
431 | 421 | <div class="row"> |
432 | | - <div class="reactions" id="reactbar" aria-label="Reactions"></div> |
| 422 | + <button class="react" id="reactbtn" title="Send reaction">😀</button> |
433 | 423 | </div> |
434 | 424 | <p style="margin-top: 10px; opacity: 0.8"> |
435 | 425 | Tip: Click one square, then another to move. Promotions auto-queen. |
|
443 | 433 | <pre id="pgn" style="white-space: pre-wrap"></pre> |
444 | 434 | </details> |
445 | 435 | </div> |
| 436 | + <div class="board" id="board" aria-label="Chess board"></div> |
446 | 437 | </div> |
| 438 | + <dialog id="emojiDialog"> |
| 439 | + <emoji-picker id="emojiPicker"></emoji-picker> |
| 440 | + </dialog> |
447 | 441 | <footer> |
448 | 442 | Built with Go & vanilla JS — with ❤️ by Dusty and his traumatized 🤖 |
449 | 443 | <div class="version"> |
|
462 | 456 | data-domain="tinychess.bitchimfabulo.us" |
463 | 457 | src="https://plausible.io/js/script.outbound-links.js" |
464 | 458 | ></script> |
| 459 | + <script |
| 460 | + type="module" |
| 461 | + src="https://cdn.jsdelivr.net/npm/emoji-picker-element@^1/index.js" |
| 462 | + ></script> |
465 | 463 | <script> |
466 | 464 | (function () { |
467 | 465 | const START_FEN = |
|
486 | 484 | const capWhiteEl = document.getElementById("cap_by_white"); |
487 | 485 | const capBlackEl = document.getElementById("cap_by_black"); |
488 | 486 | 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"); |
490 | 490 | gameIdEl.textContent = gameId || "(none)"; |
491 | 491 |
|
492 | 492 | // Orientation (default white; updated from server message) |
|
562 | 562 | let lastMoveSquares = []; // [from, to] |
563 | 563 |
|
564 | 564 | // 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 | | - ]; |
615 | 565 | const COOLDOWN_MS = 5000; |
616 | 566 | 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); |
629 | 574 | }); |
630 | 575 | } |
631 | 576 |
|
|
637 | 582 | document.body.appendChild(big); |
638 | 583 | setTimeout(() => big.remove(), 1200); |
639 | 584 |
|
640 | | - // Small burst under reactions bar |
| 585 | + // Small burst under reactions area |
641 | 586 | if (rxEl) { |
642 | 587 | const small = document.createElement("span"); |
643 | 588 | small.textContent = e; |
|
693 | 638 | } |
694 | 639 | } |
695 | 640 |
|
696 | | - buildReactBar(); |
697 | 641 |
|
698 | 642 | // --- board helpers --- |
699 | 643 | function cellSquare(row, col) { |
|
0 commit comments