Template
feat: Initial commit
This commit is contained in:
1 parent
16004f5a84
commit
04b9739853
21 files changed
+4163
No files matched your search
@@ -0,0 +1,27 @@
|
||||
const btn = document.getElementById('navAvatarBtn');
|
||||
const dropdown = document.getElementById('navDropdown');
|
||||
|
||||
if (btn && dropdown) {
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const isOpen = dropdown.classList.toggle('open');
|
||||
btn.setAttribute('aria-expanded', isOpen);
|
||||
dropdown.setAttribute('aria-hidden', !isOpen);
|
||||
});
|
||||
|
||||
document.addEventListener('click', () => {
|
||||
dropdown.classList.remove('open');
|
||||
btn.setAttribute('aria-expanded', false);
|
||||
dropdown.setAttribute('aria-hidden', true);
|
||||
});
|
||||
|
||||
dropdown.addEventListener('click', (e) => e.stopPropagation());
|
||||
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
dropdown.classList.remove('open');
|
||||
btn.setAttribute('aria-expanded', false);
|
||||
btn.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user