UNPKG

@lonelyplanet/dotcom-core

Version:

This package is meant to house some of our more common UI and shared libs across dotcom applications.

53 lines (52 loc) 2.24 kB
var __extends = (this && this.__extends) || (function () { var 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 function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; import * as Cookie from "js-cookie"; import * as React from "react"; import GlobalToast from "./index"; var Component = React.Component; var GlobalToastFromCookie = /** @class */ (function (_super) { __extends(GlobalToastFromCookie, _super); function GlobalToastFromCookie(props) { var _this = _super.call(this, props) || this; _this.state = { message: "", url: "", buttonLabel: "", type: "success", duration: 5000, animationDuration: 200, visible: false, title: "", }; return _this; } GlobalToastFromCookie.prototype.componentDidMount = function () { var toastCookie = Cookie.get("lpToast"); if (toastCookie) { return this.setState(__assign({}, this.state, JSON.parse(toastCookie), { visible: true })); } }; GlobalToastFromCookie.prototype.render = function () { return (React.createElement(GlobalToast, { message: this.state.message, buttonLabel: this.state.buttonLabel, url: this.state.url, type: this.state.type, duration: this.state.duration, animationDuration: this.state.animationDuration, visible: this.state.visible, title: this.state.title, onClose: function () { Cookie.remove("lpToast", { domain: ".lonelyplanet.com" }); } })); }; return GlobalToastFromCookie; }(React.Component)); export default GlobalToastFromCookie;