empty panel, visual tweaks

This commit is contained in:
Blue 2018-11-19 17:44:36 +03:00
parent 49cf653dba
commit b342e33912
6 changed files with 92 additions and 9 deletions

View file

@ -1,6 +1,7 @@
class Button {
constructor(image) {
this.element = document.createElement("button");
this.element.add("shadow");
this.element.style.backgroundImage = "url(images/" + image + ".svg)";
this._boundClick = this._onClick.bind(this);
this.element.addEventListener("click", this._boundClick, false);

39
ui/panel.js Normal file
View file

@ -0,0 +1,39 @@
class Panel {
constructor(width, height) {
this._width = width;
this._height = height;
this._hidden = true;
this.element = document.createElement("div");
this.element.classList.add("shadow");
this.element.classList.add("hidden");
}
setPosition(x, y) {
this.element.style.position = "absolute";
this.element.style.top = y + "px";
this.element.style.left = x + "px";
}
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;