cyp/app/js/item.js
2020-03-13 10:52:03 +01:00

23 lines
500 B
JavaScript

import * as html from "./html.js";
import { HasApp } from "./component.js";
export default class Item extends HasApp {
constructor() {
super();
this.addEventListener("click", _ => this.onClick());
}
addButton(icon, cb) {
html.button({icon}, "", this).addEventListener("click", e => {
e.stopPropagation(); // do not select
cb();
});
}
onClick() { this.parentNode.selection.toggle(this); }
_buildTitle(title) {
return html.node("span", {className:"title"}, title, this);
}
}