diff options
author | 0neGal <mail@0negal.com> | 2023-01-27 22:59:06 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-01-27 22:59:06 +0100 |
commit | feef5a6c98239a2c08433aec1bbc4e5510a79e32 (patch) | |
tree | edd7f6fc7451a2d1de0ae207e2a654eb7eeda222 /src/app/toast.js | |
parent | dee886fb40c4e8600a309a44e4a6938bcb61d51d (diff) | |
download | Viper-feef5a6c98239a2c08433aec1bbc4e5510a79e32.tar.gz Viper-feef5a6c98239a2c08433aec1bbc4e5510a79e32.zip |
move app/*.js files into app/js/
Diffstat (limited to 'src/app/toast.js')
-rw-r--r-- | src/app/toast.js | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/app/toast.js b/src/app/toast.js deleted file mode 100644 index 3bc1745..0000000 --- a/src/app/toast.js +++ /dev/null @@ -1,63 +0,0 @@ -function Toast(properties) { - let toast = { - fg: "#000000", - bg: "#FFFFFF", - timeout: 3000, - callback: () => {}, - title: "Untitled Toast", - description: "No description provided for toast", - ...properties - } - - switch(toast.scheme) { - case "error": - toast.fg = "#FFFFFF"; - toast.bg = "rgb(var(--red))"; - break - case "success": - toast.fg = "#FFFFFF"; - toast.bg = "#60D394"; - break - case "warning": - toast.fg = "#FFFFFF"; - toast.bg = "#FF9B85"; - break - } - - - let id = Date.now(); - if (document.getElementById(id)) {id = id + 1} - let el = document.createElement("div"); - - el.classList.add("toast"); - - el.style.color = toast.fg; - el.style.background = toast.bg; - - el.id = id; - el.addEventListener("click", () => { - dismissToast(id); - toast.callback(); - }) - - el.innerHTML = ` - <div class="title">${toast.title}</div> - <div class="description">${toast.description}</div> - ` - - toasts.appendChild(el); - - setTimeout(() => { - dismissToast(id); - }, toast.timeout) -} - -function dismissToast(id) { - id = document.getElementById(id); - if (id) { - id.classList.add("hidden"); - setTimeout(() => { - id.remove(); - }, 500) - } -} |