UNPKG

@rxdi/ui-kit

Version:

UI Components for building graphql-server website

85 lines (84 loc) 3.01 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RxImageComponent = void 0; const lit_html_1 = require("@rxdi/lit-html"); /** * @customElement rx-image */ let RxImageComponent = class RxImageComponent extends lit_html_1.LitElement { constructor() { super(...arguments); this.width = '80px'; this.height = '80px'; } dispatch(type) { return (detail) => { this.dispatchEvent(new CustomEvent(type === 'error' ? 'onError' : 'onLoad', { detail, })); }; } }; __decorate([ (0, lit_html_1.property)(), __metadata("design:type", Object) ], RxImageComponent.prototype, "image", void 0); __decorate([ (0, lit_html_1.property)({ type: String }), __metadata("design:type", Object) ], RxImageComponent.prototype, "width", void 0); __decorate([ (0, lit_html_1.property)({ type: String }), __metadata("design:type", Object) ], RxImageComponent.prototype, "height", void 0); RxImageComponent = __decorate([ (0, lit_html_1.Component)({ selector: 'rx-image', template() { var _a; return (0, lit_html_1.html) ` <style> :host { display: block; width: ${this.width}; height: ${this.height}; } img { visibility: hidden; width: 1px; position: absolute; height: 1px; } </style> ${((_a = this.image) === null || _a === void 0 ? void 0 : _a['_$litType$']) ? (0, lit_html_1.html) `<img />${this.image}` : (0, lit_html_1.html) `<img @load=${this.dispatch('load')} @error=${this.dispatch('error')} src=${this.image} />`} <span style=${(0, lit_html_1.styleMap)({ display: 'block', width: '100%', height: '100%', 'background-image': `url(${this.image})`, 'background-repeat': 'no-repeat', 'background-size': 'contain', })} ></span> `; }, }) ], RxImageComponent); exports.RxImageComponent = RxImageComponent; //# sourceMappingURL=image.component.js.map