MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / render

Method render

src/lib/MenuComponent.ts:107–130  ·  view source on GitHub ↗

* Render the menu buttons

()

Source from the content-addressed store, hash-verified

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
133export { MenuComponent };

Callers 1

onConfigurationUpdateMethod · 0.45

Calls 2

buttonsMethod · 0.80
keysMethod · 0.65

Tested by

no test coverage detected