MCPcopy Index your code
hub / github.com/CoderLine/alphaTab / constructor

Method constructor

packages/playground/src/components/NavMenu.ts:92–136  ·  view source on GitHub ↗
(options: NavMenuOptions = {})

Source from the content-addressed store, hash-verified

90 };
91
92 constructor(options: NavMenuOptions = {}) {
93 this.root = parseHtml(html`
94 <div class="at-nav-menu">
95 <button type="button" class="at-nav-menu-trigger" aria-haspopup="true" aria-expanded="false" aria-label="Open playground menu"></button>
96 </div>
97 `);
98 this.trigger = this.root.querySelector<HTMLButtonElement>('.at-nav-menu-trigger')!;
99 this.trigger.appendChild(renderIcon(Icons.Menu));
100
101 this.popover = parseHtml(html`<nav class="at-nav-menu-popover" role="menu"></nav>`);
102
103 const items = options.items ?? DEMOS;
104 const includeIndex = options.includeIndex ?? true;
105 const here = window.location.pathname;
106
107 if (includeIndex) {
108 const indexLink = parseHtml(
109 html`<a class="at-nav-menu-item" href="/" role="menuitem">Labs index</a>`
110 );
111 if (here === '/' || here === '/index.html') {
112 indexLink.classList.add('active');
113 }
114 this.popover.appendChild(indexLink);
115 this.popover.appendChild(parseHtml(html`<div class="at-nav-menu-divider"></div>`));
116 }
117
118 for (const item of items) {
119 const link = parseHtml(
120 html`<a class="at-nav-menu-item" href="${item.href}" role="menuitem">${item.title}</a>`
121 );
122 if (here === item.href || here === `${item.href}index.html`) {
123 link.classList.add('active');
124 }
125 this.popover.appendChild(link);
126 }
127
128 this.trigger.addEventListener('click', e => {
129 e.stopPropagation();
130 if (this.isOpen) {
131 this.close();
132 } else {
133 this.open();
134 }
135 });
136 }
137
138 private open(): void {
139 if (!this.popover.parentElement) {

Callers

nothing calls this directly

Calls 7

closeMethod · 0.95
openMethod · 0.95
parseHtmlFunction · 0.90
htmlFunction · 0.90
addMethod · 0.80
appendChildMethod · 0.65
addEventListenerMethod · 0.65

Tested by

no test coverage detected