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

Method render

src/components/quick-menu/index.ts:21–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 }
20
21 render () {
22 const buttons = (this.constructor as typeof QuickMenu).buttons ();
23
24 return buttons.map ((button) => {
25 // A user could create a custom element to display all or specific
26 // buttons. If no element was set on the button's definition, we'll
27 // assume it to be a simple button.
28 if (typeof button.element !== 'string') {
29 button.element = 'button';
30 }
31
32 const element = document.createElement (button.element);
33
34 if (typeof button.data === 'object') {
35 for (const key of Object.keys (button.data)) {
36 element.dataset[key] = button.data[key];
37 }
38 }
39
40 element.setAttribute ('icon', button.icon);
41 element.setAttribute ('string', button.string);
42 element.setAttribute ('tabindex', '0');
43
44 element.innerHTML = `
45 <span class="${button.icon}"></span>
46 <span data-string="${button.string}">${this.engine.string (button.string)}</span>
47 `;
48
49 return element.outerHTML;
50 }).join (' ');
51 }
52}
53
54export default QuickMenu;

Callers

nothing calls this directly

Calls 3

buttonsMethod · 0.80
stringMethod · 0.80
keysMethod · 0.65

Tested by

no test coverage detected