nicer delete buttons

This commit is contained in:
xenofem 2022-04-28 03:35:02 -04:00
parent 01cfcd9fcc
commit 70384b04c3
3 changed files with 19 additions and 6 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>

After

Width:  |  Height:  |  Size: 299 B

View file

@ -85,6 +85,21 @@ td {
padding: 10px; padding: 10px;
} }
td.file_delete {
background-color: #888;
mask-image: url("feather-icons/x.svg");
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
padding-left: 15px;
padding-right: 15px;
cursor: pointer;
}
td.file_delete:hover {
background-color: #f00;
}
td.file_size { td.file_size {
text-align: right; text-align: right;
} }

View file

@ -121,11 +121,8 @@ function addListEntry(file) {
const listEntry = document.createElement('tr'); const listEntry = document.createElement('tr');
const deleteButtonCell = document.createElement('td'); const deleteButtonCell = document.createElement('td');
const deleteButton = document.createElement('button'); deleteButtonCell.className = 'file_delete';
deleteButtonCell.appendChild(deleteButton); deleteButtonCell.addEventListener('click', () => {
deleteButton.className = 'file_delete';
deleteButton.textContent = 'x';
deleteButton.addEventListener('click', () => {
removeFile(file.name); removeFile(file.name);
listEntry.remove(); listEntry.remove();
updateFiles(); updateFiles();
@ -160,7 +157,7 @@ uploadButton.addEventListener('click', (e) => {
if (files.length === 0) { return; } if (files.length === 0) { return; }
fileInputContainer.remove(); fileInputContainer.remove();
for (const button of Array.from(document.getElementsByTagName('button'))) { for (const button of Array.from(document.getElementsByTagName('button')).concat(...document.getElementsByClassName('file_delete'))) {
button.remove(); button.remove();
} }