fix: move dashboard actions into compact menu
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 12s
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 12s
This commit is contained in:
37
app.js
37
app.js
@@ -35,6 +35,8 @@ const logoutButton = document.querySelector('#dashboardLogoutButton');
|
||||
const favoritesLink = document.querySelector('#favoritesLink');
|
||||
const adminPanelLink = document.querySelector('#adminPanelLink');
|
||||
const userBadge = document.querySelector('#dashboardUserBadge');
|
||||
const dashboardMenuButton = document.querySelector('#dashboardMenuButton');
|
||||
const dashboardMenuPanel = document.querySelector('#dashboardMenuPanel');
|
||||
|
||||
function normalize(value) {
|
||||
return String(value || '').toLowerCase().trim();
|
||||
@@ -491,6 +493,23 @@ viewOptions.forEach((option) => {
|
||||
|
||||
searchInput.addEventListener('input', updateVisibility);
|
||||
|
||||
function closeDashboardMenu() {
|
||||
if (!dashboardMenuButton || !dashboardMenuPanel) return;
|
||||
dashboardMenuButton.setAttribute('aria-expanded', 'false');
|
||||
dashboardMenuButton.classList.remove('is-open');
|
||||
dashboardMenuPanel.classList.remove('is-open');
|
||||
dashboardMenuPanel.hidden = true;
|
||||
}
|
||||
|
||||
function toggleDashboardMenu() {
|
||||
if (!dashboardMenuButton || !dashboardMenuPanel) return;
|
||||
const isOpen = dashboardMenuButton.getAttribute('aria-expanded') === 'true';
|
||||
dashboardMenuButton.setAttribute('aria-expanded', String(!isOpen));
|
||||
dashboardMenuButton.classList.toggle('is-open', !isOpen);
|
||||
dashboardMenuPanel.classList.toggle('is-open', !isOpen);
|
||||
dashboardMenuPanel.hidden = isOpen;
|
||||
}
|
||||
|
||||
function updateAuthNav() {
|
||||
const authenticated = MischLabsAuth.isAuthenticated();
|
||||
const claims = MischLabsAuth.claims();
|
||||
@@ -507,6 +526,24 @@ function updateAuthNav() {
|
||||
}
|
||||
}
|
||||
|
||||
dashboardMenuButton?.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
toggleDashboardMenu();
|
||||
});
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
if (!dashboardMenuPanel || dashboardMenuPanel.hidden) return;
|
||||
if (!event.target.closest('.dashboard-menu')) {
|
||||
closeDashboardMenu();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Escape') {
|
||||
closeDashboardMenu();
|
||||
}
|
||||
});
|
||||
|
||||
loginButton?.addEventListener('click', () => MischLabsAuth.login());
|
||||
logoutButton?.addEventListener('click', () => MischLabsAuth.logout());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user