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

Method render

src/components/main-menu/index.ts:8–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6 static override tag = 'main-menu';
7
8 override render(): string {
9 const staticContext = this.constructor as typeof MainMenu;
10 return staticContext.buttons().map((button: MenuButton) => {
11 // A user could create a custom element to display all or specific
12 // buttons. If no element was set on the button's definition, we'll
13 // assume it to be a simple button.
14 if (typeof button.element !== 'string') {
15 button.element = 'button';
16 }
17
18 const element = document.createElement(button.element);
19
20 if (typeof button.data === 'object') {
21 for (const key of Object.keys(button.data)) {
22 element.dataset[key] = button.data[key];
23 }
24 }
25
26 element.setAttribute('icon', button.icon);
27 element.setAttribute('string', button.string);
28
29 element.setAttribute('tabindex', '0');
30
31 element.innerHTML = `
32 <span class="${button.icon}"></span>
33 <span data-string="${button.string}">${this.engine.string(button.string)}</span>
34 `;
35
36 return element.outerHTML;
37 }).join(' ');
38 }
39}
40
41export default MainMenu;

Callers

nothing calls this directly

Calls 3

buttonsMethod · 0.80
stringMethod · 0.80
keysMethod · 0.65

Tested by

no test coverage detected