Created
November 20, 2020 08:41
-
-
Save fredriccliver/ccde29cba4574db571839a75cd7e520f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class UI { | |
toastTemplate?: HTMLTemplateElement | |
constructor(templateSelector: string) { | |
this.toastTemplate = document.querySelector<HTMLTemplateElement>( | |
templateSelector | |
)! | |
} | |
showToast() { | |
if (!!this.toastTemplate) { | |
let div = document.createElement('div') | |
div.innerHTML = this.toastTemplate.innerHTML | |
const appendedChild = document.body.appendChild(div) | |
setTimeout(() => { | |
console.log(`time is done`) | |
this.hideToast(appendedChild) | |
}, 1000) | |
} | |
} | |
hideToast(toast: HTMLElement) { | |
toast.remove() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment