fantasy/ui/panel.js
2018-11-20 15:17:27 +03:00

40 lines
884 B
JavaScript

import UI from "./ui.js";
class Panel extends UI {
constructor(width, height) {
super(document.createElement("div"), width, height);
this._hidden = true;
this.element.classList.add("panel");
this.element.classList.add("shadow");
this.element.classList.add("hidden");
this._children = [];
}
add(ui) {
this._children.push(ui);
this.element.appendChild(ui.element);
}
toggle() {
if (this._hidden) {
this.show();
} else {
this.hide();
}
}
show() {
if (this._hidden) {
this.element.classList.remove("hidden");
this._hidden = false;
}
}
hide() {
if (!this._hidden) {
this.element.classList.add("hidden");
this._hidden = true;
}
}
}
export default Panel;