From 4312610e7d35a8ce3ccfa4ba8f7ae7e523c38e4c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 17 Jun 2021 16:45:53 +0200 Subject: [PATCH] support menu options with custom DOM --- src/platform/web/ui/general/Menu.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/platform/web/ui/general/Menu.js b/src/platform/web/ui/general/Menu.js index 2fed5e2d..be5dea1d 100644 --- a/src/platform/web/ui/general/Menu.js +++ b/src/platform/web/ui/general/Menu.js @@ -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)); + } }