noti-alert
Version:
Una simple librería de notificaciones para JavaScript puro.
2 lines (1 loc) • 1.31 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NotiAlert={})}(this,(function(e){"use strict";!function(e,t){void 0===t&&(t={});var o=t.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".noti-alert{background-color:#444;border-radius:6px;box-shadow:0 0 10px rgba(0,0,0,.2);color:#fff;font-family:sans-serif;margin-top:10px;padding:12px 20px;position:fixed;right:20px;top:20px;transition:opacity .5s,transform .5s;z-index:10000}.noti-alert.info{background-color:#2196f3}.noti-alert.success{background-color:#4caf50}.noti-alert.error{background-color:#f44336}.noti-alert.warning{background-color:#ff9800}.noti-alert.hide{opacity:0;transform:translateY(-20px)}"),e.showNotification=function(e,t="info",o=3e3){const n=document.createElement("div");n.className=`noti-alert ${t}`,n.textContent=e,document.body.appendChild(n),setTimeout((()=>{n.classList.add("hide"),setTimeout((()=>n.remove()),500)}),o)}}));