import { demoFunc } from './dees-modal.demo.js'; import { customElement, html, DeesElement, property, type TemplateResult, cssManager, css, type CSSResult, unsafeCSS, unsafeHTML, state, } from '@design.estate/dees-element'; import * as domtools from '@design.estate/dees-domtools'; import { DeesWindowLayer } from './dees-windowlayer.js'; declare global { interface HTMLElementTagNameMap { 'dees-modal': DeesModal; } } @customElement('dees-modal') export class DeesModal extends DeesElement { // STATIC public static demo = demoFunc; public static async createAndShow(optionsArg: { heading: string; content: TemplateResult }) { const body = document.body; const modal = new DeesModal(); modal.heading = optionsArg.heading; modal.content = optionsArg.content; modal.windowLayer = await DeesWindowLayer.createAndShow(); modal.windowLayer.addEventListener('click', async () => { await modal.destroy(); }); body.append(modal.windowLayer); body.append(modal); } // INSTANCE @property({ type: String, }) public heading = ''; @state({}) public content: TemplateResult; constructor() { super(); } public static styles = [ cssManager.defaultStyles, css` :host { font-family: 'Mona Sans', 'Inter', sans-serif; color: ${cssManager.bdTheme('#333', '#fff')}; } .modalContainer { display: flex; position: fixed; width: 100vw; height: 100vh; box-sizing: border-box; align-items: center; justify-content: center; z-index: 2000; } .modal { will-change: transform; transform: translateY(10px); opacity: 0; width: 480px; min-height: 120px; background: #111; border-radius: 8px; border: 1px solid #222; transition: all 0.2s; overflow: hidden; } .modal.show { opacity: 1; transform: translateY(0px); } .modal .heading { height: 32px; font-family: 'Hubot Sans', 'Inter', sans-serif; line-height: 32px; text-align: center; font-weight: 600; font-size: 12px; border-bottom: 1px solid #222; } .modal .content { padding: 16px; } .modal .bottomButtons { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #222; } .modal .bottomButtons .bottomButton { height: 40px; line-height: 40px; text-align: center; font-size: 14px; border-right: 1px solid #222; cursor: pointer; } .modal .bottomButtons .bottomButton:hover { background: #222; } .modal .bottomButtons .bottomButton:last-child { border-right: none; } `, ]; public render(): TemplateResult { return html`