UNPKG

@rxdi/ui-kit

Version:

UI Components for building graphql-server website

118 lines (116 loc) 4.45 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); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AlertComponent = void 0; const lit_html_1 = require("@rxdi/lit-html"); /** * @customElement rx-alert */ let AlertComponent = class AlertComponent extends lit_html_1.LitElement { onClose() { this.dispatchEvent(new CustomEvent('onClose', { detail: this })); this.remove(); } OnUpdateFirst() { if (this.palette === 'primary') { this.setPaletteStyle('#d8eafc', '#1e87f0'); } else if (this.palette === 'success') { this.setPaletteStyle('#edfbf6', '#32d296'); } else if (this.palette === 'warning') { this.setPaletteStyle('#fff6ee', '#faa05a'); } else if (this.palette === 'danger') { this.setPaletteStyle('#fef4f6', '#f0506e'); } else if (this.palette === 'default') { this.setPaletteStyle('#f8f8f8', '#666'); } } setPaletteStyle(backgroundColor, color) { this.paletteStyle = (0, lit_html_1.css) ` :host { background: ${(0, lit_html_1.unsafeCSS)(backgroundColor)}; color: ${(0, lit_html_1.unsafeCSS)(color)}; } `; } }; __decorate([ (0, lit_html_1.property)({ type: String }), __metadata("design:type", String) ], AlertComponent.prototype, "palette", void 0); __decorate([ (0, lit_html_1.property)({ type: Object }), __metadata("design:type", lit_html_1.CSSResult) ], AlertComponent.prototype, "paletteStyle", void 0); __decorate([ (0, lit_html_1.property)({ type: Boolean }), __metadata("design:type", Boolean) ], AlertComponent.prototype, "transition", void 0); AlertComponent = __decorate([ (0, lit_html_1.Component)({ selector: 'rx-alert', style: (0, lit_html_1.css) ` :host { position: relative; padding: 15px 29px 15px 15px; } slot { font-size: 15px; font-weight: normal; line-height: 1.5; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; } a { position: absolute; top: 15px; right: 15px; color: inherit; opacity: 0.4; } a:hover { cursor: pointer; color: inherit; opacity: 0.8; } `, template() { return (0, lit_html_1.html) ` <style> ${this.paletteStyle} </style> <a @click=${() => __awaiter(this, void 0, void 0, function* () { return this.onClose(); })}> ${(0, lit_html_1.svg) ` <svg width="14" height="14" viewBox="0 0 14 14"> <line fill="none" stroke="#666" stroke-width="1.1" x1="1" y1="1" x2="13" y2="13"></line> <line fill="none" stroke="#666" stroke-width="1.1" x1="13" y1="1" x2="1" y2="13"></line> </svg> `}</a > <slot part="text"></slot> `; } }) ], AlertComponent); exports.AlertComponent = AlertComponent; //# sourceMappingURL=alert.component.js.map