feat: add click-to-open profile dropdown with z-index fix and mobile JS handler
Add JavaScript click handler for profile dropdown toggle in MobileNav, replace anchor with button in base template, add explicit profile link to dropdown menu, and apply z-index to nav-badge for proper stacking.
This commit is contained in:
@@ -539,7 +539,7 @@ img {
|
||||
.topnav-icon { position: relative; padding: 0.375rem; color: var(--text-secondary); font-size: 1.25rem; background: none; border: none; cursor: pointer; font-family: inherit; line-height: 1; }
|
||||
.topnav-icon:hover { color: var(--text-primary); }
|
||||
.nav-badge {
|
||||
position: absolute; top: 0; right: 0; min-width: 16px; height: 16px;
|
||||
position: absolute; top: 0; right: 0; z-index: 1; min-width: 16px; height: 16px;
|
||||
padding: 0 0.25rem; border-radius: 8px; background: var(--accent); color: var(--white);
|
||||
font-size: 0.6875rem; font-weight: 700;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
@@ -568,7 +568,8 @@ img {
|
||||
padding: 0.25rem 0;
|
||||
z-index: 1001;
|
||||
}
|
||||
.topnav-user-dropdown:hover .dropdown-menu { display: block; }
|
||||
.topnav-user-dropdown:hover .dropdown-menu,
|
||||
.topnav-user-dropdown.open .dropdown-menu { display: block; }
|
||||
.dropdown-item {
|
||||
display: block;
|
||||
padding: 0.5rem 0.875rem;
|
||||
|
||||
@@ -3,6 +3,7 @@ export class MobileNav {
|
||||
this.initMobileNav();
|
||||
this.initMessagesResponsive();
|
||||
this.initMessageThread();
|
||||
this.initProfileDropdown();
|
||||
}
|
||||
|
||||
initMobileNav() {
|
||||
@@ -92,4 +93,28 @@ export class MobileNav {
|
||||
const thread = document.querySelector(".messages-thread");
|
||||
if (thread) thread.scrollTop = thread.scrollHeight;
|
||||
}
|
||||
|
||||
initProfileDropdown() {
|
||||
const dropdown = document.querySelector(".topnav-user-dropdown");
|
||||
if (!dropdown) return;
|
||||
const btn = dropdown.querySelector(".topnav-user");
|
||||
if (!btn) return;
|
||||
|
||||
btn.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
dropdown.classList.toggle("open");
|
||||
});
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
if (!dropdown.contains(e.target)) {
|
||||
dropdown.classList.remove("open");
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape") {
|
||||
dropdown.classList.remove("open");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user