Improve navigator UI and context actions

This commit is contained in:
Mikei386
2026-06-22 22:40:50 +02:00
parent 20205cddc0
commit f29ecb0be5
9 changed files with 176 additions and 15 deletions
@@ -29,17 +29,28 @@ Code="f07b"
}
const wrapper = toolsLink.parentElement?.tagName === 'LI' ? toolsLink.parentElement : toolsLink;
const item = wrapper.cloneNode(true);
const link = item.tagName === 'A' ? item : item.querySelector('a');
if (!link) {
return;
}
const isListItem = wrapper.tagName === 'LI';
const item = isListItem ? document.createElement('li') : document.createElement('a');
const link = isListItem ? document.createElement('a') : item;
link.className = toolsLink.className || '';
link.href = targetHref;
link.textContent = targetText;
link.setAttribute('data-u-navigator-nav', 'true');
link.classList.remove('active', 'selected');
item.classList?.remove('active', 'selected');
link.classList.remove('active', 'selected', 'on');
if (isListItem) {
item.className = wrapper.className || '';
item.classList.remove('active', 'selected', 'on');
item.appendChild(link);
}
if (location.pathname === targetHref) {
toolsLink.classList.remove('active', 'selected', 'on');
wrapper.classList?.remove('active', 'selected', 'on');
link.classList.add('active');
item.classList?.add('active');
}
wrapper.insertAdjacentElement('afterend', item);
}