mirror of
https://github.com/picocss/pico.git
synced 2025-04-22 01:26:13 -04:00
20 lines
No EOL
491 B
JavaScript
20 lines
No EOL
491 B
JavaScript
function showNotification(options = {}) {
|
|
const dialog = document.querySelector("dialog[role='alert']");
|
|
|
|
if (options.text || typeof options === "string") {
|
|
dialog.innerText = options.text || options;
|
|
} else if (options.html) {
|
|
dialog.innerHTML = options.html;
|
|
}
|
|
|
|
dialog.showModal();
|
|
|
|
setTimeout(() => {
|
|
dialog.close();
|
|
}, options.delay || 3000);
|
|
}
|
|
|
|
function closeNotification() {
|
|
const dialog = document.querySelector("dialog[role='alert']");
|
|
dialog.close();
|
|
} |