add delete step button

This commit is contained in:
Michi 2024-11-12 21:37:17 +01:00
parent 1b6c6c0f91
commit 85bc8eaf43
3 changed files with 42 additions and 1 deletions

View file

@ -116,6 +116,7 @@ function createStepElement(label, description, imgSrc, triggerAction, triggerEle
// create container for text & image
const textContainer = document.createElement("div");
const stepControls = document.createElement("div");
const imgContainer = document.createElement("div");
// create title
@ -135,6 +136,23 @@ function createStepElement(label, description, imgSrc, triggerAction, triggerEle
image.src = imgSrc;
imgContainer.appendChild(image);
// create stepcontrol + delete button
const delBtn = document.createElement("button");
const delBtnIcon = document.createElement("span");
delBtn.textContent = "Delete step";
delBtnIcon.className = "material-symbols-outlined";
delBtnIcon.textContent = "delete";
delBtn.appendChild(delBtnIcon);
delBtn.addEventListener('click', function(){
// remove step
event.target.parentNode.parentNode.parentNode.remove();
});
stepControls.classList = "stepControls editor";
stepControls.appendChild(delBtn);
textContainer.appendChild(stepControls);
// append to main container
container.appendChild(textContainer);
container.appendChild(imgContainer);