2018-07-05 19:09:00 +02:00
|
|
|
import { createElement } from "./createElement";
|
2018-07-05 19:23:12 +02:00
|
|
|
import { getElementById } from "./getElementById";
|
2018-07-05 19:09:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the necessary DOM elements to present an in-game popup to the player.
|
|
|
|
* @param id The (hopefully) unique identifier for the popup container.
|
|
|
|
* @param elems The collection of HTML Elements to show within the popup.
|
|
|
|
*/
|
|
|
|
export function createPopup(id: string, elems: HTMLElement[]) {
|
|
|
|
const container: HTMLDivElement = createElement("div", {
|
|
|
|
class: "popup-box-container",
|
2018-08-12 21:45:35 +02:00
|
|
|
display: "flex",
|
2018-07-18 18:49:46 +02:00
|
|
|
id,
|
2018-07-05 19:09:00 +02:00
|
|
|
}) as HTMLDivElement;
|
|
|
|
const content: HTMLElement = createElement("div", {
|
|
|
|
class: "popup-box-content",
|
|
|
|
id: `${id}-content`,
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const elem of elems) {
|
|
|
|
content.appendChild(elem);
|
|
|
|
}
|
|
|
|
container.appendChild(content);
|
2018-07-05 19:23:12 +02:00
|
|
|
getElementById("entire-game-container")
|
|
|
|
.appendChild(container);
|
2018-07-05 19:09:00 +02:00
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|