react-toast-messages
Version:
React toast messages
66 lines • 2.85 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
require("./assets/style.scss");
var AwesomeToggleSwitch = /** @class */ (function (_super) {
__extends(AwesomeToggleSwitch, _super);
function AwesomeToggleSwitch(props) {
var _this = _super.call(this, props) || this;
_this.state = {
show: false,
status: props.status ? props.status : '',
message: props.message ? props.message : '',
timeout: props.timeout ? props.timeout : ''
};
return _this;
}
AwesomeToggleSwitch.prototype.componentDidUpdate = function (prevProps) {
if (this.props.message !== prevProps.message && this.props.message !== '') {
this.start();
}
};
AwesomeToggleSwitch.prototype.start = function () {
var self = this;
this.setState({
show: true
});
var int = setTimeout(function () {
clearTimeout();
console.info('this is the problem');
self.closeToaster({});
window.clearTimeout(int);
}, self.state.timeout);
};
AwesomeToggleSwitch.prototype.closeToaster = function (e) {
clearTimeout();
this.setState({
show: false,
message: ''
});
};
AwesomeToggleSwitch.prototype.render = function () {
var _this = this;
var toRender = this.state.message !== '' || this.state.show ? React.createElement("div", { className: "toastMessage_wrapper" },
React.createElement("div", { className: "toastMessage toastMessage-show" },
React.createElement("span", { className: "toastMessage_status toastMessage-" + this.state.status }),
React.createElement("span", { className: "toastMessage_message" }, this.props.message),
React.createElement("span", { className: "toastMessage_close", onClick: function (e) { return _this.closeToaster(e); } }, "\u00D7"))) : '';
return (React.createElement("div", { className: 'toastMessageContainer' }, toRender));
};
return AwesomeToggleSwitch;
}(React.Component));
exports.default = AwesomeToggleSwitch;
//# sourceMappingURL=index.js.map