cyp/app/js/elements/menu.js
Ondrej Zara 2957ded7d8 cleanup
2020-03-28 18:31:28 +01:00

24 lines
634 B
JavaScript

import Component from "../component.js";
class Menu extends Component {
_onAppLoad() {
/** @type HTMLElement[] */
this._tabs = Array.from(this.querySelectorAll("[data-for]"));
this._tabs.forEach(tab => {
tab.addEventListener("click", _ => this._app.setAttribute("component", tab.dataset.for));
});
this._app.addEventListener("queue-length-change", e => {
this.querySelector(".queue-length").textContent = `(${e.detail})`;
});
}
_onComponentChange(component) {
this._tabs.forEach( tab => {
tab.classList.toggle("active", tab.dataset.for == component);
});
}
}
customElements.define("cyp-menu", Menu);