UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

35 lines 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.showToast = exports.ToastsPart = void 0; const _1 = require("."); const selective_edit_1 = require("@blinkk/selective-edit"); const toast_1 = require("../ui/toast"); const events_1 = require("../events"); const selective_edit_2 = require("@blinkk/selective-edit"); /** * Toasts are centralized in the display to be outside of other * modals and structures. Toast elements live as siblings in the * DOM. */ class ToastsPart extends _1.BasePart { constructor() { super(); this.toasts = []; document.addEventListener(events_1.EVENT_TOAST_SHOW, (evt) => { const newToast = new toast_1.Toast(evt.detail); this.toasts.unshift(newToast); newToast.show(); }); } template(editor) { return selective_edit_1.html `<div class="le__part__toasts"> ${selective_edit_2.repeat(this.toasts, toast => toast.uid, toast => toast.template(editor))} </div>`; } } exports.ToastsPart = ToastsPart; function showToast(toast) { document.dispatchEvent(new CustomEvent(events_1.EVENT_TOAST_SHOW, { detail: toast })); } exports.showToast = showToast; //# sourceMappingURL=toasts.js.map