Add back in flash messages

This commit is contained in:
Tristan Daniël Maat 2022-08-01 16:35:28 +01:00
parent 3ba6f08986
commit 49f7360df1
Signed by: tlater
GPG key ID: 49670FD774E43268
5 changed files with 45 additions and 11 deletions

30
src/lib/js/index.ts Normal file
View file

@ -0,0 +1,30 @@
document.addEventListener("DOMContentLoaded", () => {
let flashButtons = document.querySelectorAll(".notification .delete");
flashButtons.forEach((button) => {
let flash = button.parentNode;
if (flash == null) {
console.error(
"Unreachable because our `querySelector` includes a parent; something went very wrong"
);
return;
}
flash.addEventListener("click", () => {
if (flash == null) {
console.error("Completely unreachable.");
return;
}
if (flash.parentNode == null) {
console.error(
"Notification not placed in DOM; something went very wrong"
);
return;
}
flash.parentNode.removeChild(flash);
});
});
});