forked from mystiq/hydrogen-web
support menu options with custom DOM
This commit is contained in:
parent
70d64f38eb
commit
4312610e7d
1 changed files with 14 additions and 12 deletions
|
@ -27,18 +27,7 @@ export class Menu extends TemplateView {
|
|||
}
|
||||
|
||||
render(t) {
|
||||
return t.ul({className: "menu", role: "menu"}, this._options.map(o => {
|
||||
const className = {
|
||||
destructive: o.destructive,
|
||||
};
|
||||
if (o.icon) {
|
||||
className.icon = true;
|
||||
className[o.icon] = true;
|
||||
}
|
||||
return t.li({
|
||||
className,
|
||||
}, t.button({onClick: o.callback}, o.label));
|
||||
}));
|
||||
return t.ul({className: "menu", role: "menu"}, this._options.map(o => o.toDOM(t)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,4 +48,17 @@ class MenuOption {
|
|||
this.destructive = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
toDOM(t) {
|
||||
const className = {
|
||||
destructive: this.destructive,
|
||||
};
|
||||
if (this.icon) {
|
||||
className.icon = true;
|
||||
className[this.icon] = true;
|
||||
}
|
||||
return t.li({
|
||||
className,
|
||||
}, t.button({onClick: this.callback}, this.label));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue