22 lines
500 B
JavaScript
22 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);
|
|
}
|
|
}
|