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.

14 lines
394 B

  1. export default function toast(duration: number, message: HTMLElement | string): void {
  2. let element = document.createElement('div');
  3. element.classList.add("toast");
  4. if (typeof(message) == 'string') {
  5. element.innerText = message;
  6. } else {
  7. element.appendChild(message);
  8. }
  9. document.body.appendChild(element);
  10. setTimeout(() => {
  11. element.remove();
  12. }, duration * 1000);
  13. }