Skip to content

Commit 8491274

Browse files
committed
Fix mobile header background and sidebar toggle
- Add background-color to #nav-header in critical CSS (fixes transparent header on mobile while Tailwind loads) - Add dark mode background for header in critical CSS - Fix mobile sidebar toggle stretching to full content height by switching .documentation to flex-direction: column on mobile - Change .mobile-sidebar-toggle to display:none by default, show only on mobile via media query - Add click handler for #mobile-sidebar-toggle to open/close sidebar drawer and backdrop - Remove duplicate .docs-nav display:none media query
1 parent 78f3bdd commit 8491274

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

_frontend/entrypoints/application.css

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@
125125
margin: 0;
126126
}
127127

128-
@media (max-width: 1023px) {
129-
.docs-nav {
130-
display: none;
131-
}
132-
}
133-
134128
/* ===== Sidebar navigation ===== */
135129
.docs-nav .nav-section {
136130
margin-bottom: 1.5rem;
@@ -286,7 +280,7 @@
286280

287281
/* ===== Mobile sidebar toggle ===== */
288282
.mobile-sidebar-toggle {
289-
display: flex;
283+
display: none;
290284
align-items: center;
291285
gap: 0.5rem;
292286
padding: 0.5rem 0.75rem;
@@ -315,9 +309,12 @@
315309
background: #3730a3;
316310
}
317311

318-
@media (min-width: 1024px) {
312+
@media (max-width: 1023px) {
313+
.documentation {
314+
flex-direction: column;
315+
}
319316
.mobile-sidebar-toggle {
320-
display: none;
317+
display: flex;
321318
}
322319
}
323320

_frontend/entrypoints/application.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ import '../js/theme.js'
22
import '../js/navigation.js'
33

44
document.addEventListener('DOMContentLoaded', function() {
5+
// Mobile sidebar toggle (in-page button)
6+
var sidebarToggle = document.getElementById('mobile-sidebar-toggle');
7+
var sidebar = document.querySelector('.docs-nav');
8+
var backdrop = document.querySelector('.docs-nav-backdrop');
9+
if (sidebarToggle && sidebar) {
10+
sidebarToggle.addEventListener('click', function() {
11+
sidebar.classList.toggle('mobile-open');
12+
if (backdrop) backdrop.classList.toggle('active');
13+
});
14+
}
15+
if (backdrop) {
16+
backdrop.addEventListener('click', function() {
17+
sidebar.classList.remove('mobile-open');
18+
backdrop.classList.remove('active');
19+
});
20+
}
21+
522
// Active header nav — highlight Standards/Resources/About
623
var currentPath = window.location.pathname;
724
document.querySelectorAll('[data-nav-section]').forEach(function(el) {

_includes/head.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
html{scroll-behavior:smooth!important}
2222
body{font-feature-settings:"kern" 1,"liga" 1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:#fff!important;color:#1e293b!important;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,sans-serif!important;opacity:1!important}
2323
html.dark body{background-color:#0f172a!important;color:#f1f5f9!important}
24-
#nav-header{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:50!important;height:64px!important}
24+
#nav-header{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:50!important;height:64px!important;background-color:#fff!important}
25+
html.dark #nav-header{background-color:#0f172a!important}
2526
main{padding-top:64px!important}
2627
</style>
2728

0 commit comments

Comments
 (0)