addColor Refactor

This commit is contained in:
Leamsi Escribano 2021-07-04 17:36:15 -04:00
parent 0d545fba25
commit ba50aa3369

View File

@ -162,10 +162,10 @@ const ColorModule = (() => {
newColor = '#' + newColor; newColor = '#' + newColor;
currentPalette.push(newColor); currentPalette.push(newColor);
//create list item //create list item
var listItem = document.createElement('li'); const listItem = document.createElement('li');
//create button //create button
var button = document.createElement('button'); const button = document.createElement('button');
button.classList.add('color-button'); button.classList.add('color-button');
button.style.backgroundColor = newColor; button.style.backgroundColor = newColor;
button.addEventListener('mouseup', clickedColor); button.addEventListener('mouseup', clickedColor);
@ -179,13 +179,11 @@ const ColorModule = (() => {
initColor(button); initColor(button);
//add edit button //add edit button
var editButtonTemplate = document.getElementsByClassName('color-edit-button')[0]; const editButtonTemplate = document.getElementsByClassName('color-edit-button')[0];
newEditButton = editButtonTemplate.cloneNode(true); newEditButton = editButtonTemplate.cloneNode(true);
listItem.appendChild(newEditButton); listItem.appendChild(newEditButton);
//when you click the edit button newEditButton.addEventListener('click', (e,button) => {
on('click', newEditButton, function (event, button) {
//hide edit button //hide edit button
button.parentElement.lastChild.classList.add('hidden'); button.parentElement.lastChild.classList.add('hidden');