Skip to content

Commit 5271e18

Browse files
committed
feat: replace fade with sliding active indicator in sidebar nav
1 parent 47c20f0 commit 5271e18

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

public/css/style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,18 @@ cap-widget {
594594
flex: 1;
595595
padding: 16px 12px;
596596
overflow-y: auto;
597+
position: relative;
598+
}
599+
600+
.nav-indicator {
601+
position: absolute;
602+
left: 0;
603+
width: 3px;
604+
background: var(--accent-1);
605+
border-radius: 0 4px 4px 0;
606+
transition: top var(--transition), height var(--transition), opacity var(--transition);
607+
pointer-events: none;
608+
z-index: 1;
597609
}
598610

599611
.nav-section-label {

public/js/app.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ async function renderDashboard() {
443443
</a>
444444
</div>
445445
<nav class="sidebar-nav">
446+
<div class="nav-indicator" id="nav-indicator"></div>
446447
<div class="nav-section-label">Main</div>
447448
<a class="nav-item active" data-page="overview" href="/overview">
448449
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>
@@ -584,11 +585,25 @@ function navigateTo(page) {
584585
}
585586
}
586587

588+
updateNavIndicator();
589+
587590
if (window.innerWidth <= 768) {
588591
$('#sidebar').classList.remove('open');
589592
}
590593
}
591594

595+
function updateNavIndicator() {
596+
const activeNav = document.querySelector('.nav-item.active');
597+
const indicator = document.getElementById('nav-indicator');
598+
if (activeNav && indicator) {
599+
indicator.style.top = activeNav.offsetTop + 'px';
600+
indicator.style.height = activeNav.offsetHeight + 'px';
601+
indicator.style.opacity = '1';
602+
} else if (indicator) {
603+
indicator.style.opacity = '0';
604+
}
605+
}
606+
592607
window.addEventListener('popstate', () => {
593608
const path = window.location.pathname;
594609
const parts = path.replace(/^\//, '').split('/');
@@ -625,6 +640,7 @@ window.addEventListener('popstate', () => {
625640
renderLog();
626641
}
627642
}
643+
updateNavIndicator();
628644
});
629645

630646
// ===== OVERVIEW =====

0 commit comments

Comments
 (0)