pwa-toast.entry.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { r as registerInstance, h, g as getElement, H as Host } from './index-1c5c47b4.js';
  2. 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)}";
  3. const PWAToast = class {
  4. constructor(hostRef) {
  5. registerInstance(this, hostRef);
  6. this.message = undefined;
  7. this.duration = 2000;
  8. this.closing = null;
  9. }
  10. hostData() {
  11. const classes = {
  12. out: !!this.closing
  13. };
  14. if (this.closing !== null) {
  15. classes['in'] = !this.closing;
  16. }
  17. return {
  18. class: classes
  19. };
  20. }
  21. componentDidLoad() {
  22. setTimeout(() => {
  23. this.closing = false;
  24. });
  25. setTimeout(() => {
  26. this.close();
  27. }, this.duration);
  28. }
  29. close() {
  30. this.closing = true;
  31. setTimeout(() => {
  32. this.el.parentNode.removeChild(this.el);
  33. }, 1000);
  34. }
  35. __stencil_render() {
  36. return (h("div", { class: "wrapper" }, h("div", { class: "toast" }, this.message)));
  37. }
  38. get el() { return getElement(this); }
  39. render() { return h(Host, this.hostData(), this.__stencil_render()); }
  40. };
  41. PWAToast.style = toastCss;
  42. export { PWAToast as pwa_toast };