cyp/app/js/item.js
2020-03-12 23:03:26 +01:00

21 lines
464 B
JavaScript

import * as html from "./html.js";
export default class Item extends HTMLElement {
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);
}
}