Skip to content

Commit

Permalink
colorselect interactive preview update
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Aug 16, 2024
1 parent 244a884 commit 6e10d31
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/assets/js/ColorSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ function moveAddButton(slot) {
prevAddSlot.onclick = null; // Remove the click handler for empty slots
}

// Update the newly filled slot
// Update the newly filled slot (ensures the color is displayed correctly)
currentSlot.classList.remove('empty');
currentSlot.classList.remove('add-slot');
currentSlot.style.backgroundColor = ''; // Clear the background color
currentSlot.onclick = function() {
editColor(slot);
};
Expand Down Expand Up @@ -195,7 +196,6 @@ function deleteSlot(slot) {
currentSlotElement.innerHTML = '';
currentSlotElement.style.cursor = 'default'; // Remove pointer cursor
currentSlotElement.onclick = null;
break; // Stop shifting once the next slot is empty
}
}

Expand All @@ -212,6 +212,19 @@ function deleteSlot(slot) {
editColor(filledSlots + 1);
};
}

// Ensure that the slot after the add button is correctly updated
for (let i = filledSlots + 2; i <= 8; i++) {
const slotToCheck = document.getElementById(`slot${i}`);
if (slotToCheck) {
slotToCheck.classList.add('empty');
slotToCheck.classList.remove('add-slot');
slotToCheck.style.backgroundColor = '#222'; // Darker background for empty slots
slotToCheck.innerHTML = '';
slotToCheck.style.cursor = 'default';
slotToCheck.onclick = null;
}
}
}

// Handle holding and deleting
Expand Down

0 comments on commit 6e10d31

Please sign in to comment.