Skip to content

Commit 2b6ec32

Browse files
Dennis Braunclaude
andcommitted
Fix mobile sidebar: use overlay mode instead of width toggle
On mobile (≤900px) the sidebar was hidden by CSS width:0 which overrode the JS collapsed-class toggle. Now uses position:fixed with translateX for a slide-in overlay, a backdrop for tap-to-close, and auto-closes when selecting a menu item. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 613dd65 commit 2b6ec32

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

app/templates/index.html

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -658,14 +658,25 @@
658658
vertical-align: middle; margin-left: 6px;
659659
}
660660

661+
/* ── Sidebar overlay backdrop ── */
662+
.sidebar-backdrop {
663+
display: none; position: fixed; inset: 0;
664+
background: var(--overlay); z-index: 59;
665+
}
666+
.sidebar-backdrop.active { display: block; }
667+
661668
/* ── Responsive ── */
662669
@media (max-width: 900px) {
663670
.charts-grid { grid-template-columns: 1fr; }
664-
.sidebar { width: 0; min-width: 0; }
665-
.sidebar.collapsed { width: 0; min-width: 0; }
666-
}
667-
@media (max-width: 900px) {
668671
.metric-cards { grid-template-columns: 1fr; }
672+
.sidebar {
673+
position: fixed; top: 0; left: 0; bottom: 0;
674+
z-index: 60; width: 240px; min-width: 240px;
675+
transform: translateX(-100%);
676+
transition: transform 0.25s ease;
677+
}
678+
.sidebar.collapsed { width: 240px; min-width: 240px; transform: translateX(-100%); }
679+
.sidebar.mobile-open { transform: translateX(0); }
669680
}
670681
@media (max-width: 600px) {
671682
body { font-size: 14px; }
@@ -752,6 +763,7 @@
752763
</div>
753764
</div>
754765
</nav>
766+
<div class="sidebar-backdrop" id="sidebar-backdrop"></div>
755767

756768
<!-- Main Area -->
757769
<div class="app-main">
@@ -1600,18 +1612,35 @@ <h2>{{ t.export_title }}</h2>
16001612

16011613
/* ── Sidebar ── */
16021614
var sidebar = document.getElementById('sidebar');
1615+
var sidebarBackdrop = document.getElementById('sidebar-backdrop');
16031616

1604-
function collapseSidebar() { sidebar.classList.add('collapsed'); }
1605-
function expandSidebar() { sidebar.classList.remove('collapsed'); }
1617+
function isMobile() { return window.matchMedia('(max-width: 900px)').matches; }
1618+
1619+
function collapseSidebar() {
1620+
sidebar.classList.add('collapsed');
1621+
sidebar.classList.remove('mobile-open');
1622+
sidebarBackdrop.classList.remove('active');
1623+
}
1624+
function expandSidebar() {
1625+
sidebar.classList.remove('collapsed');
1626+
}
16061627

16071628
document.getElementById('sidebar-collapse').addEventListener('click', collapseSidebar);
16081629
document.getElementById('hamburger').addEventListener('click', function() {
1609-
sidebar.classList.toggle('collapsed');
1630+
if (isMobile()) {
1631+
var opening = !sidebar.classList.contains('mobile-open');
1632+
sidebar.classList.toggle('mobile-open', opening);
1633+
sidebarBackdrop.classList.toggle('active', opening);
1634+
} else {
1635+
sidebar.classList.toggle('collapsed');
1636+
}
16101637
});
1638+
sidebarBackdrop.addEventListener('click', collapseSidebar);
16111639

16121640
var sidebarLinks = document.querySelectorAll('.sidebar-link[data-view]');
16131641
sidebarLinks.forEach(function(link) {
16141642
link.addEventListener('click', function() {
1643+
if (isMobile()) { collapseSidebar(); }
16151644
switchView(this.getAttribute('data-view'));
16161645
});
16171646
});

0 commit comments

Comments
 (0)