UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
86 lines (85 loc) 2.95 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Mask = void 0; const lit_1 = require("lit"); const decorators_js_1 = require("lit/decorators.js"); const context_1 = require("../context"); const context_2 = require("@lit/context"); let Mask = class Mask extends lit_1.LitElement { constructor() { super(...arguments); this.binded = false; } shouldUpdate(changedProperties) { for (const prop of changedProperties.keys()) { if (prop !== 'appState') return true; } const newLoading = this.appState.loading; if (newLoading !== this.previousLoading) { this.previousLoading = newLoading; return true; } const newLoadingMessage = this.appState.loadingMessage; if (newLoadingMessage !== this.previousLoadingMessage) { this.previousLoadingMessage = newLoadingMessage; return true; } return false; } render() { if (!this.api) { return; } const { loading, loadingMessage } = this.appState; return (0, lit_1.html) ` <div class="mask" style=${loading ? 'display: flex;' : 'display: none;'}> ${loading ? (0, lit_1.html) ` <sp-progress-circle size="s" label="Loading content" indeterminate ></sp-progress-circle> <div class="loading">${loadingMessage}</div>` : ''} </div> `; } }; exports.Mask = Mask; Mask.styles = (0, lit_1.css) ` .mask { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; } .loading { margin-left: 8px; color: white; font-size: 16px; font-weight: bold; } `; __decorate([ (0, context_2.consume)({ context: context_1.appStateContext, subscribe: true }) ], Mask.prototype, "appState", void 0); __decorate([ (0, context_2.consume)({ context: context_1.apiContext, subscribe: true }) ], Mask.prototype, "api", void 0); exports.Mask = Mask = __decorate([ (0, decorators_js_1.customElement)('ic-spectrum-mask') ], Mask); //# sourceMappingURL=mask.js.map