improvements and style changes of adding name to team functionality

This commit is contained in:
2025-06-04 15:20:36 -07:00
parent 9bf808c761
commit d5dd306d74
3 changed files with 53 additions and 2 deletions

Binary file not shown.

View File

@@ -118,8 +118,30 @@ function waitForCategorySelection(customName, squareEl, squareNumber) {
document.querySelectorAll('.categories').forEach(cat => { document.querySelectorAll('.categories').forEach(cat => {
cat.classList.add('category-selectable'); cat.classList.add('category-selectable');
}); });
// --- Add overlay to dim only the map area with transition ---
let mapWrapper = document.getElementById('mapWrapper');
let overlay = document.createElement('div');
overlay.id = 'category-select-overlay';
overlay.style.position = 'absolute';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.background = 'rgba(0,0,0,0.55)';
overlay.style.zIndex = '999';
overlay.style.pointerEvents = 'auto';
overlay.style.opacity = '0';
overlay.style.transition = 'opacity 0.3s ease';
mapWrapper.appendChild(overlay);
// Trigger fade-in
requestAnimationFrame(() => {
overlay.style.opacity = '1';
});
// --- end overlay ---
const msg = document.createElement('div'); const msg = document.createElement('div');
msg.textContent = 'Click a category to add "' + customName + '"'; msg.innerHTML = 'Select a team to add <span style="color:#d103f9;">' + customName + '</span> to';
msg.className = 'category-select-msg'; msg.className = 'category-select-msg';
msg.style.position = 'absolute'; msg.style.position = 'absolute';
msg.style.top = '40%'; msg.style.top = '40%';
@@ -133,6 +155,27 @@ function waitForCategorySelection(customName, squareEl, squareNumber) {
msg.style.fontSize = '1.1em'; msg.style.fontSize = '1.1em';
document.body.appendChild(msg); document.body.appendChild(msg);
// --- Overlay click cancels the add operation ---
overlay.addEventListener('click', function cancelAddFruit() {
// Remove highlight/selectable from categories
document.querySelectorAll('.categories').forEach(cat => {
cat.classList.remove('category-selectable');
cat.removeEventListener('click', onCategoryClick, true);
});
// Remove overlay and message
document.body.removeChild(msg);
overlay.style.opacity = '0';
setTimeout(() => {
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
}, 300);
// Restore the square to its original state (just the number)
squareEl.innerHTML = '';
const numDiv = document.createElement('div');
numDiv.className = 'square-number';
numDiv.textContent = squareNumber;
squareEl.appendChild(numDiv);
});
// Handler for category click // Handler for category click
function onCategoryClick(e) { function onCategoryClick(e) {
e.stopPropagation(); e.stopPropagation();
@@ -141,6 +184,14 @@ function waitForCategorySelection(customName, squareEl, squareNumber) {
cat.removeEventListener('click', onCategoryClick, true); cat.removeEventListener('click', onCategoryClick, true);
}); });
document.body.removeChild(msg); document.body.removeChild(msg);
// --- Remove overlay with fade-out ---
if (overlay && overlay.parentNode) {
overlay.style.opacity = '0';
setTimeout(() => {
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
}, 300);
}
// --- end remove overlay ---
// Find category name // Find category name
const catHeader = e.currentTarget.querySelector('.category-header h4'); const catHeader = e.currentTarget.querySelector('.category-header h4');