@aire-ux/aire-overlay
Version:
84 lines (81 loc) • 2.55 kB
JavaScript
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 { css, html, LitElement } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
let Overlay = class Overlay extends LitElement {
constructor() {
super(...arguments);
this.handleResize = () => {
const host = this.parentElement;
if (host) {
// this.style.width = `${host.clientWidth}px`;
// this.style.height = `${host.clientHeight - 2}px`;
// this.style.left = 'unset';
// this.style.top = 'unset';
}
};
}
connectedCallback() {
super.connectedCallback();
window.addEventListener('resize', this.handleResize);
}
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener('resize', this.handleResize);
}
render() {
const host = this.parentElement;
return html `
<style>
:host {
top: 0px;
left: 0px;
width: ${host?.clientWidth}px;
height: ${(host?.clientHeight || 0) - 2}px;
}
</style>
<slot name="header" part="header"></slot>
<slot name="content" part="content"></slot>
<slot name="footer" part="footer"></slot>
`;
}
};
// language=CSS
Overlay.styles = css `
:host {
background-color: white;
z-index: 150;
display: flex;
flex-direction: column;
top: unset;
left: unset;
}
::slotted(header) {
height:48px;
display: flex;
flex-direction: row;
padding: 0 16px;
align-items: center;
}
::slotted(article) {
flex-grow: 1;
display: flex;
flex-direction: column;
max-height: 100%;
overflow-y: auto;
height: 100%;
}
::slotted(footer) {
height:32px;
display: flex;
flex-direction: row;
}
`;
Overlay = __decorate([
customElement('aire-overlay')
], Overlay);
export { Overlay };