From 2c0709eeee3621ba3b0177cc9afe0c6c57152424 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 16 Dec 2020 16:04:02 +0100 Subject: [PATCH] web: render SidebarItem from the item --- web/src/elements/sidebar/Sidebar.ts | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/web/src/elements/sidebar/Sidebar.ts b/web/src/elements/sidebar/Sidebar.ts index 144c90c24..54f191323 100644 --- a/web/src/elements/sidebar/Sidebar.ts +++ b/web/src/elements/sidebar/Sidebar.ts @@ -65,6 +65,32 @@ export class SidebarItem { } }); } + + async render(activePath: string): Promise { + if (this.condition) { + const result = await this.condition(); + if (!result) { + return html``; + } + } + return html`
  • + ${this.path ? + html` + ${this.name} + ` : + html` + ${this.name} + + + + +
    +
      + ${this._children.map((i) => until(i.render(activePath), html``))} +
    +
    `} +
  • `; + } } @customElement("ak-sidebar") @@ -118,37 +144,11 @@ export class Sidebar extends LitElement { }); } - async renderItem(item: SidebarItem): Promise { - if (item.condition) { - const result = await item.condition(); - if (!result) { - return html``; - } - } - return html`
  • - ${item.path ? - html` - ${item.name} - ` : - html` - ${item.name} - - - - -
    -
      - ${item._children.map((i) => until(this.renderItem(i), html``))} -
    -
    `} -
  • `; - } - render(): TemplateResult { return html``;