UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
103 lines (98 loc) 3.73 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.LayersPanelItem = void 0; const lit_1 = require("lit"); const decorators_js_1 = require("lit/decorators.js"); const when_js_1 = require("lit/directives/when.js"); const context_1 = require("@lit/context"); const context_2 = require("../context"); let LayersPanelItem = class LayersPanelItem extends lit_1.LitElement { constructor() { super(...arguments); this.selected = false; } handleToggleVisibility() { this.api.updateNode(this.node, { visibility: this.node.visibility === 'visible' ? 'hidden' : 'visible', }); } render() { const isVisible = this.node.visibility === 'visible'; return (0, lit_1.html) `<span> <sp-action-button quiet size="s" @click=${this.handleToggleVisibility}> ${(0, when_js_1.when)(isVisible, () => (0, lit_1.html) `<sp-icon-visibility slot="icon"></sp-icon-visibility>`, () => (0, lit_1.html) `<sp-icon-visibility-off slot="icon" ></sp-icon-visibility-off>`)} <sp-tooltip self-managed placement="left"> Hide layer </sp-tooltip> </sp-action-button> <ic-spectrum-layer-thumbnail .node=${this.node} ?selected=${this.selected} ></ic-spectrum-layer-thumbnail> </span> <ic-spectrum-layer-name .node=${this.node}></ic-spectrum-layer-name> <div class="layer-actions" style="visibility: ${this.selected ? 'visible' : 'hidden'};"> <sp-action-button quiet size="m"> <sp-icon-properties slot="icon"></sp-icon-properties> <sp-tooltip self-managed placement="bottom"> Layer properties</sp-tooltip > </sp-action-button> </div> </span>`; } }; exports.LayersPanelItem = LayersPanelItem; LayersPanelItem.styles = (0, lit_1.css) ` :host { width: 320px; height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 4px; cursor: pointer; } :host > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; } ic-spectrum-layer-name { flex: 1; } :host([selected]) { background: var(--spectrum-blue-100); } :host(:not([selected]):not([disabled]):hover) { background-color: var( --spectrum-treeview-item-background-color-hover, var(--spectrum-alias-background-color-hover-overlay) ); } :host([child]) > span { padding-left: 24px; } `; __decorate([ (0, decorators_js_1.property)() ], LayersPanelItem.prototype, "node", void 0); __decorate([ (0, decorators_js_1.property)({ type: Boolean }) ], LayersPanelItem.prototype, "selected", void 0); __decorate([ (0, context_1.consume)({ context: context_2.apiContext, subscribe: true }) ], LayersPanelItem.prototype, "api", void 0); exports.LayersPanelItem = LayersPanelItem = __decorate([ (0, decorators_js_1.customElement)('ic-spectrum-layers-panel-item') ], LayersPanelItem); //# sourceMappingURL=layers-panel-item.js.map