Modularize frontend app script
This commit is contained in:
11
wwwroot/js/dom.js
Normal file
11
wwwroot/js/dom.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export const $ = (id) => document.getElementById(id);
|
||||
|
||||
const toastEl = typeof document !== "undefined" ? document.getElementById("toast") : null;
|
||||
|
||||
export function toast(msg, isError = false) {
|
||||
if (!toastEl) return;
|
||||
toastEl.textContent = msg;
|
||||
toastEl.classList.remove("hidden");
|
||||
toastEl.classList.toggle("error", isError);
|
||||
setTimeout(() => toastEl.classList.add("hidden"), 2000);
|
||||
}
|
||||
Reference in New Issue
Block a user