vdk-components
Version:
React component library built with TypeScript and SCSS
3 lines (2 loc) • 1.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VDKToast={},e.jsxRuntime,e.React)}(this,(function(e,t,s){"use strict";e.Toast=function(e){var n=e.message,o=e.type,a=void 0===o?"info":o,r=e.duration,i=void 0===r?3e3:r,c=e.onClose,u=e.className,l=void 0===u?"":u;s.useEffect((function(){if(i>0){var e=setTimeout((function(){null==c||c()}),i);return function(){return clearTimeout(e)}}}),[i,c]);var f=["toast","toast--".concat(a),l].filter(Boolean).join(" ");return t.jsxs("div",{className:f,role:"alert",children:[t.jsx("div",{className:"toast__icon",children:function(){switch(a){case"success":return"✓";case"error":return"✕";case"warning":return"⚠";case"info":return"ℹ";default:return""}}()}),t.jsx("div",{className:"toast__message",children:n}),c&&t.jsx("button",{className:"toast__close",onClick:c,"aria-label":"Close",children:"×"}),t.jsx("div",{className:"toast__progress",style:{animationDuration:"".concat(i,"ms")}})]})}}));
//# sourceMappingURL=index.umd.js.map