UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
91 lines (87 loc) 3.51 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.LayersPanel = void 0; const lit_1 = require("lit"); const context_1 = require("@lit/context"); const map_js_1 = require("lit/directives/map.js"); const decorators_js_1 = require("lit/decorators.js"); const context_2 = require("../context"); let LayersPanel = class LayersPanel extends lit_1.LitElement { handleClose() { this.api.setTaskbars(this.appState.taskbarSelected.filter((task) => task !== context_2.Task.SHOW_LAYERS_PANEL)); } handleSelect(e, id) { this.api.selectNodes([id], e.shiftKey); } render() { const { layersSelected, taskbarSelected } = this.appState; return taskbarSelected.includes(context_2.Task.SHOW_LAYERS_PANEL) ? (0, lit_1.html) `<section> <h4> Layers <sp-action-button quiet size="s" @click=${this.handleClose}> <sp-icon-close slot="icon"></sp-icon-close> </sp-action-button> </h4> <div class="layers-container"> ${(0, map_js_1.map)(this.nodes, (node) => { // TODO: hierarchy // TODO: virtual scroll for better performance return (0, lit_1.html) `<ic-spectrum-layers-panel-item .node=${node} draggable @click=${(e) => this.handleSelect(e, node.id)} ?selected=${layersSelected.includes(node.id)} ?child=${!!node.parentId} ></ic-spectrum-layers-panel-item>`; })} </div> </section>` : null; } }; exports.LayersPanel = LayersPanel; LayersPanel.styles = (0, lit_1.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; } .layers-container { height: 300px; overflow: hidden; overflow-y: auto; } `; __decorate([ (0, context_1.consume)({ context: context_2.appStateContext, subscribe: true }) ], LayersPanel.prototype, "appState", void 0); __decorate([ (0, context_1.consume)({ context: context_2.nodesContext, subscribe: true }) ], LayersPanel.prototype, "nodes", void 0); __decorate([ (0, context_1.consume)({ context: context_2.apiContext, subscribe: true }) ], LayersPanel.prototype, "api", void 0); exports.LayersPanel = LayersPanel = __decorate([ (0, decorators_js_1.customElement)('ic-spectrum-layers-panel') ], LayersPanel); //# sourceMappingURL=layers-panel.js.map