UNPKG

wired-elements

Version:

Collection of hand-drawn sketchy web components

119 lines (117 loc) 3.53 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { css, html, LitElement } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { WiredCard } from './wired-card'; let WiredDialog = class WiredDialog extends LitElement { constructor() { super(...arguments); this.elevation = 5; this.open = false; } static get styles() { return css ` #container { position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: var(--wired-dialog-z-index, 100); } #container::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.5s ease; } #overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0; transform: translateY(150px); transition: transform 0.5s ease, opacity 0.5s ease; } .layout.vertical { display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; } .flex { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; } wired-card { display: inline-block; background: white; text-align: left; } :host([open]) #container { pointer-events: auto; } :host([open]) #container::before { opacity: 1; } :host([open]) #overlay { opacity: 1; transform: none; } `; } render() { return html ` <div id="container"> <div id="overlay" class="vertical layout"> <div class="flex"></div> <div style="text-align: center; padding: 5px;"> <wired-card .elevation="${this.elevation}"><slot></slot></wired-card> </div> <div class="flex"></div> </div> </div> `; } updated() { if (this.card) { this.card.wiredRender(true); } } }; __decorate([ property({ type: Number }), __metadata("design:type", Object) ], WiredDialog.prototype, "elevation", void 0); __decorate([ property({ type: Boolean, reflect: true }), __metadata("design:type", Object) ], WiredDialog.prototype, "open", void 0); __decorate([ query('wired-card'), __metadata("design:type", WiredCard) ], WiredDialog.prototype, "card", void 0); WiredDialog = __decorate([ customElement('wired-dialog') ], WiredDialog); export { WiredDialog };