UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
95 lines (91 loc) 3.5 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 { html, css, LitElement } from 'lit'; import { consume } from '@lit/context'; import { customElement } from 'lit/decorators.js'; import { Task, } from '@infinite-canvas-tutorial/ecs'; import { apiContext, appStateContext, nodesContext } from '../context'; import { localized, msg, str } from '@lit/localize'; let PropertiesPanel = class PropertiesPanel extends LitElement { handleClose() { this.api.setAppState({ taskbarSelected: this.appState.taskbarSelected.filter((task) => task !== Task.SHOW_PROPERTIES_PANEL), }); } render() { var _a; const { layersSelected, taskbarSelected } = this.appState; const enabled = taskbarSelected.includes(Task.SHOW_PROPERTIES_PANEL); if (!enabled) { return null; } // Display selected panel if (layersSelected.length > 1) { return html `<section> <h4> ${msg(str `Properties`)} <sp-action-button quiet size="s" @click=${this.handleClose}> <sp-icon-close slot="icon"></sp-icon-close> </sp-action-button> </h4> <div class="container">${layersSelected.length} selected</div> </section>`; } const node = (_a = this.api) === null || _a === void 0 ? void 0 : _a.getNodeById(layersSelected[0]); return html `<section> <h4> Properties <sp-action-button quiet size="s" @click=${this.handleClose}> <sp-icon-close slot="icon"></sp-icon-close> </sp-action-button> </h4> <ic-spectrum-properties-panel-content .node=${node} ></ic-spectrum-properties-panel-content> </section>`; } }; PropertiesPanel.styles = css ` section { display: flex; flex-direction: column; background: var(--spectrum-gray-100); border-radius: var(--spectrum-corner-radius-200); margin: 4px; filter: drop-shadow( var(--spectrum-drop-shadow-color) 0px var(--spectrum-drop-shadow-y) var(--spectrum-drop-shadow-blur) ); } h4 { padding: var(--spectrum-global-dimension-size-100); display: flex; align-items: center; justify-content: space-between; margin: 0; color: canvastext; } .container { padding: var(--spectrum-global-dimension-size-100); padding-top: 0; } `; __decorate([ consume({ context: appStateContext, subscribe: true }) ], PropertiesPanel.prototype, "appState", void 0); __decorate([ consume({ context: nodesContext, subscribe: true }) ], PropertiesPanel.prototype, "nodes", void 0); __decorate([ consume({ context: apiContext, subscribe: true }) ], PropertiesPanel.prototype, "api", void 0); PropertiesPanel = __decorate([ customElement('ic-spectrum-properties-panel'), localized() ], PropertiesPanel); export { PropertiesPanel }; //# sourceMappingURL=properties-panel.js.map