mirror of
https://github.com/picocss/pico.git
synced 2025-04-20 16:46:14 -04:00
V. 2.1.0 - Yohns Fork
This commit is contained in:
parent
b611b528bc
commit
42b62b10a6
10 changed files with 66 additions and 38 deletions
20
docs/js/Notifications.js
Normal file
20
docs/js/Notifications.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue