pwa-toast.cjs.entry.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. const index = require('./index-d7f36e37.js');
  4. const toastCss = ":host{position:fixed;bottom:20px;left:0;right:0;display:-ms-flexbox;display:flex;opacity:0}:host(.in){-webkit-transition:opacity 300ms;transition:opacity 300ms;opacity:1}:host(.out){-webkit-transition:opacity 1s;transition:opacity 1s;opacity:0}.wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.toast{font-family:-apple-system, system-ui, \"Helvetica Neue\", Roboto, sans-serif;background-color:#eee;color:black;border-radius:5px;padding:10px 15px;font-size:14px;font-weight:500;-webkit-box-shadow:0px 1px 2px rgba(0, 0, 0, 0.20);box-shadow:0px 1px 2px rgba(0, 0, 0, 0.20)}";
  5. const PWAToast = class {
  6. constructor(hostRef) {
  7. index.registerInstance(this, hostRef);
  8. this.message = undefined;
  9. this.duration = 2000;
  10. this.closing = null;
  11. }
  12. hostData() {
  13. const classes = {
  14. out: !!this.closing
  15. };
  16. if (this.closing !== null) {
  17. classes['in'] = !this.closing;
  18. }
  19. return {
  20. class: classes
  21. };
  22. }
  23. componentDidLoad() {
  24. setTimeout(() => {
  25. this.closing = false;
  26. });
  27. setTimeout(() => {
  28. this.close();
  29. }, this.duration);
  30. }
  31. close() {
  32. this.closing = true;
  33. setTimeout(() => {
  34. this.el.parentNode.removeChild(this.el);
  35. }, 1000);
  36. }
  37. __stencil_render() {
  38. return (index.h("div", { class: "wrapper" }, index.h("div", { class: "toast" }, this.message)));
  39. }
  40. get el() { return index.getElement(this); }
  41. render() { return index.h(index.Host, this.hostData(), this.__stencil_render()); }
  42. };
  43. PWAToast.style = toastCss;
  44. exports.pwa_toast = PWAToast;