mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Fix Menu: Use t instead of tag to get events
- Also move constructor up Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
8d254c91e3
commit
a3271fb916
@ -15,9 +15,14 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {TemplateView} from "./TemplateView.js";
|
import {TemplateView} from "./TemplateView.js";
|
||||||
import { tag } from "./html.js";
|
|
||||||
|
|
||||||
export class Menu extends TemplateView {
|
export class Menu extends TemplateView {
|
||||||
|
|
||||||
|
constructor(options) {
|
||||||
|
super();
|
||||||
|
this._options = options;
|
||||||
|
}
|
||||||
|
|
||||||
static optionWithButton(label, callback) {
|
static optionWithButton(label, callback) {
|
||||||
const option = new MenuOption(label);
|
const option = new MenuOption(label);
|
||||||
option.setCallback(callback);
|
option.setCallback(callback);
|
||||||
@ -30,17 +35,12 @@ export class Menu extends TemplateView {
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(options) {
|
_convertToDOM(t, option) {
|
||||||
super();
|
|
||||||
this._options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
_convertToDOM(option) {
|
|
||||||
if (option.callback) {
|
if (option.callback) {
|
||||||
return tag.button({ className: "menu-item", onClick: option.callback }, option.label);
|
return t.button({ className: "menu-item", onClick: option.callback }, option.label);
|
||||||
}
|
}
|
||||||
else if (option.link) {
|
else if (option.link) {
|
||||||
return tag.a({ className: "menu-item", href: option.link }, option.label);
|
return t.a({ className: "menu-item", href: option.link }, option.label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export class Menu extends TemplateView {
|
|||||||
}
|
}
|
||||||
return t.li({
|
return t.li({
|
||||||
className,
|
className,
|
||||||
}, this._convertToDOM(o));
|
}, this._convertToDOM(t, o));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user