mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-11 04:27:40 +01:00
support menu options with custom DOM
This commit is contained in:
parent
70d64f38eb
commit
4312610e7d
@ -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…
x
Reference in New Issue
Block a user