Convert toast and confirm to TypeScript (#5219)

This commit is contained in:
StableCrimson
2025-04-17 19:12:18 -05:00
committed by GitHub
parent 26a0bc44b8
commit de246b060e
4 changed files with 96 additions and 80 deletions
@@ -1,6 +1,10 @@
import './toast.scss';
let toastContainer;
interface Toast {
text: string
}
let toastContainer: HTMLDivElement;
function getToastContainer() {
if (!toastContainer) {
@@ -12,24 +16,24 @@ function getToastContainer() {
return toastContainer;
}
function remove(elem) {
function remove(elem: HTMLElement) {
setTimeout(function () {
elem.parentNode.removeChild(elem);
elem.parentNode?.removeChild(elem);
}, 300);
}
function animateRemove(elem) {
function animateRemove(elem: HTMLElement) {
setTimeout(function () {
elem.classList.add('toastHide');
remove(elem);
}, 3300);
}
export default function (options) {
export default function (options: string | Toast) {
if (typeof options === 'string') {
options = {
text: options
};
} as Toast;
}
const elem = document.createElement('div');