fantasy/ui/panel.js

37 lines
821 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");
}
add(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;