* Render the menu buttons
()
| 105 | * Render the menu buttons |
| 106 | */ |
| 107 | render (): string { |
| 108 | const staticContext = this.constructor as typeof MenuComponent; |
| 109 | return staticContext.buttons().map((button: MenuButton) => { |
| 110 | // A user could create a custom element to display all or specific |
| 111 | // buttons. If no element was set on the button's definition, we'll |
| 112 | // assume it to be a simple button. |
| 113 | if (typeof button.element !== 'string') { |
| 114 | button.element = 'button'; |
| 115 | } |
| 116 | |
| 117 | const element = document.createElement(button.element); |
| 118 | |
| 119 | if (typeof button.data === 'object') { |
| 120 | for (const key of Object.keys(button.data)) { |
| 121 | element.dataset[key] = button.data[key]; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | element.setAttribute('icon', button.icon); |
| 126 | element.setAttribute('string', button.string); |
| 127 | |
| 128 | return element.outerHTML; |
| 129 | }).join(' '); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | export { MenuComponent }; |
no test coverage detected