UNPKG

@uimkit/uikit-react

Version:

<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>

23 lines (20 loc) 900 B
import 'react'; function Toast(props) { var _a = props.type, type = _a === void 0 ? 'info' : _a, text = props.text, propsTime = props.time, className = props.className; var time = propsTime || 3; var root = document.body; var elements = document.createElement('div'); elements.innerText = text; elements.className = "toast ".concat(className, " ").concat(type); root.appendChild(elements); var toastList = document.getElementsByClassName('toast'); elements.style.left = "calc(50% - ".concat(elements.clientWidth / 2, "px)"); elements.style.zIndex = "".concat(10 + toastList.length - 1); elements.style.top = "".concat(elements.clientHeight * (toastList.length - 1), "px"); var Timer = setTimeout(function () { root.removeChild(elements); clearTimeout(Timer); }, time * 1000); } export { Toast }; //# sourceMappingURL=index.js.map