less prototype, less bad code implementation of CCHM type theory
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

15 lines
394 B

export default function toast(duration: number, message: HTMLElement | string): void {
let element = document.createElement('div');
element.classList.add("toast");
if (typeof(message) == 'string') {
element.innerText = message;
} else {
element.appendChild(message);
}
document.body.appendChild(element);
setTimeout(() => {
element.remove();
}, duration * 1000);
}