2021-02-13 21:52:36 +00:00
|
|
|
import { customElement, LitElement, TemplateResult, html, property } from 'lit-element';
|
|
|
|
|
|
|
|
import * as domtools from '@designestate/dees-domtools';
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
'dees-windowlayer': DeesWindowLayer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@customElement('dees-windowlayer')
|
|
|
|
export class DeesWindowLayer extends LitElement {
|
2021-09-01 19:48:22 +00:00
|
|
|
// STATIC
|
2021-02-13 21:52:36 +00:00
|
|
|
public static demo = () => html`<dees-windowlayer></dees-windowlayer>`;
|
|
|
|
|
2021-09-01 19:48:22 +00:00
|
|
|
// INSTANCE
|
|
|
|
@property({
|
|
|
|
type: Boolean
|
|
|
|
})
|
|
|
|
public visible = false;
|
|
|
|
|
2021-02-13 21:52:36 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
domtools.elementBasic.setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
${domtools.elementBasic.styles}
|
|
|
|
<style>
|
|
|
|
.windowOverlay {
|
2021-09-01 19:48:22 +00:00
|
|
|
transition: all 0.3s;
|
2021-08-29 15:10:25 +00:00
|
|
|
will-change: transform;
|
2021-02-13 21:52:36 +00:00
|
|
|
position: fixed;
|
|
|
|
top: 0px;
|
|
|
|
left: 0px;
|
|
|
|
height: 100vh;
|
|
|
|
width: 100vw;
|
2021-08-29 15:10:25 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2021-02-13 21:52:36 +00:00
|
|
|
background: rgba(0, 0, 0, 0.0);
|
2021-09-01 19:48:22 +00:00
|
|
|
backdrop-filter: brightness(1);
|
|
|
|
pointer-events: none;
|
2021-02-13 21:52:36 +00:00
|
|
|
}
|
2021-08-29 15:10:25 +00:00
|
|
|
|
2021-02-13 21:52:36 +00:00
|
|
|
.visible {
|
|
|
|
background: rgba(0, 0, 0, 0.2);
|
2021-08-29 15:10:25 +00:00
|
|
|
backdrop-filter: brightness(0.3);
|
2021-09-01 19:48:22 +00:00
|
|
|
pointer-events: all;
|
2021-02-13 21:52:36 +00:00
|
|
|
}
|
|
|
|
</style>
|
2021-09-01 19:48:22 +00:00
|
|
|
<div @click=${this.dispatchClicked} class="windowOverlay ${this.visible ? 'visible' : null}">
|
2021-02-13 21:52:36 +00:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
firstUpdated() {
|
|
|
|
setTimeout(() => {
|
2021-09-01 19:48:22 +00:00
|
|
|
this.visible = true;
|
2021-02-13 21:52:36 +00:00
|
|
|
}, 100);
|
|
|
|
}
|
2021-09-01 19:48:22 +00:00
|
|
|
|
|
|
|
dispatchClicked() {
|
|
|
|
this.dispatchEvent(new CustomEvent('clicked'))
|
|
|
|
}
|
|
|
|
|
|
|
|
public toggleVisibility () {
|
|
|
|
this.visible = !this.visible;
|
|
|
|
}
|
2021-02-13 21:52:36 +00:00
|
|
|
}
|