Add back in flash messages
This commit is contained in:
parent
3ba6f08986
commit
49f7360df1
5 changed files with 45 additions and 11 deletions
30
src/lib/js/index.ts
Normal file
30
src/lib/js/index.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
});
|
Reference in a new issue