// Copyright Epic Games, Inc. All Rights Reserved. "use strict"; import { Component } from "./component.js" //////////////////////////////////////////////////////////////////////////////// export class Modal { constructor() { const body = new Component(document.body); this._root = body.tag().classify("zen_modal"); const bg = this._root.tag().classify("zen_modal_bg"); bg.on("click", () => this._root.destroy()); const rect = this._root.tag(); this._title = rect.tag().classify("zen_modal_title"); this._content = rect.tag().classify("zen_modal_message"); this._buttons = rect.tag().classify("zen_modal_buttons"); } title(value) { this._title.text(value); return this; } message(value) { this._content.text(value); return this; } option(name, func, ...args) { const thunk = () => { this._root.destroy(); if (func) func(...args); }; this._buttons.tag().text(name).on("click", thunk); return this; } }