UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
83 lines (82 loc) 2.75 kB
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; }; import { css, html, LitElement } from 'lit'; import { customElement } from 'lit/decorators.js'; import { apiContext, appStateContext } from '../context'; import { consume } from '@lit/context'; let Mask = class Mask extends 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 html ` <div class="mask" style=${loading ? 'display: flex;' : 'display: none;'}> ${loading ? html ` <sp-progress-circle size="s" label="Loading content" indeterminate ></sp-progress-circle> <div class="loading">${loadingMessage}</div>` : ''} </div> `; } }; Mask.styles = 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([ consume({ context: appStateContext, subscribe: true }) ], Mask.prototype, "appState", void 0); __decorate([ consume({ context: apiContext, subscribe: true }) ], Mask.prototype, "api", void 0); Mask = __decorate([ customElement('ic-spectrum-mask') ], Mask); export { Mask }; //# sourceMappingURL=mask.js.map