UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
100 lines (95 loc) 3.44 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 { customElement, property } from 'lit/decorators.js'; import { when } from 'lit/directives/when.js'; import { consume } from '@lit/context'; import { apiContext } from '../context'; let LayersPanelItem = class LayersPanelItem extends 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 html `<span> <sp-action-button quiet size="s" @click=${this.handleToggleVisibility}> ${when(isVisible, () => html `<sp-icon-visibility slot="icon"></sp-icon-visibility>`, () => 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>`; } }; LayersPanelItem.styles = 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([ property() ], LayersPanelItem.prototype, "node", void 0); __decorate([ property({ type: Boolean }) ], LayersPanelItem.prototype, "selected", void 0); __decorate([ consume({ context: apiContext, subscribe: true }) ], LayersPanelItem.prototype, "api", void 0); LayersPanelItem = __decorate([ customElement('ic-spectrum-layers-panel-item') ], LayersPanelItem); export { LayersPanelItem }; //# sourceMappingURL=layers-panel-item.js.map