Skip to content

Commit d012699

Browse files
michaelmcneesclaude
andcommitted
fix: improve mobile navigation and layouts on docs site
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e04e15 commit d012699

4 files changed

Lines changed: 80 additions & 31 deletions

File tree

site/src/components/DocsSidebar.astro

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function isParentActive(item: NavItem): boolean {
111111
<a
112112
href={item.href}
113113
class:list={[
114-
'flex items-center justify-between px-3 py-1.5 text-[13px] transition-colors',
114+
'flex items-center justify-between px-3 py-2 text-sm transition-colors',
115115
active
116116
? 'text-primary font-medium border-l-2 border-primary bg-primary/5'
117117
: 'text-on-surface-variant hover:text-on-surface border-l-2 border-transparent hover:border-outline-variant',
@@ -140,7 +140,7 @@ function isParentActive(item: NavItem): boolean {
140140
<a
141141
href={child.href}
142142
class:list={[
143-
'block pl-6 pr-3 py-1 text-[12px] transition-colors',
143+
'block pl-6 pr-3 py-1.5 text-[13px] transition-colors',
144144
childActive
145145
? 'text-primary font-medium border-l-2 border-primary bg-primary/5'
146146
: 'text-on-surface-variant/80 hover:text-on-surface border-l-2 border-outline-variant/30 hover:border-outline-variant',
@@ -159,32 +159,39 @@ function isParentActive(item: NavItem): boolean {
159159
</ul>
160160
</div>
161161
))}
162+
163+
<!-- Site navigation -->
164+
<div class="mt-4 pt-4 border-t border-outline-variant">
165+
<h4 class="text-[10px] font-headline font-bold uppercase tracking-[0.15em] text-on-surface-variant/60 mb-3 px-3">
166+
Site
167+
</h4>
168+
<ul>
169+
<li>
170+
<a href="/" class="flex items-center gap-2 px-3 py-2 text-sm text-on-surface-variant hover:text-on-surface transition-colors">
171+
Home
172+
</a>
173+
</li>
174+
<li>
175+
<a href="https://github.com/dvflw/mantle" class="flex items-center gap-2 px-3 py-2 text-sm text-on-surface-variant hover:text-on-surface transition-colors">
176+
GitHub
177+
</a>
178+
</li>
179+
</ul>
180+
</div>
162181
</nav>
163182
</aside>
164183

165184
<script is:inline>
166185
function initSidebar() {
167-
const toggleBtn = document.getElementById('sidebar-toggle');
168186
const mobileSidebar = document.getElementById('docs-sidebar-mobile');
169187
const overlay = document.getElementById('sidebar-overlay');
170-
if (!toggleBtn || !mobileSidebar || !overlay) return;
188+
if (!mobileSidebar || !overlay) return;
171189

172-
function openSidebar() {
173-
mobileSidebar.classList.remove('-translate-x-full');
174-
overlay.classList.remove('hidden');
175-
}
176190
function closeSidebar() {
177191
mobileSidebar.classList.add('-translate-x-full');
178192
overlay.classList.add('hidden');
179193
}
180194

181-
const newBtn = toggleBtn.cloneNode(true);
182-
toggleBtn.parentNode?.replaceChild(newBtn, toggleBtn);
183-
newBtn.addEventListener('click', () => {
184-
const isOpen = !mobileSidebar.classList.contains('-translate-x-full');
185-
if (isOpen) closeSidebar(); else openSidebar();
186-
});
187-
188195
const newOverlay = overlay.cloneNode(true);
189196
overlay.parentNode?.replaceChild(newOverlay, overlay);
190197
newOverlay.addEventListener('click', closeSidebar);

site/src/components/Nav.astro

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,31 @@ const isDocs = !isHome;
5959
function initNav() {
6060
const btn = document.getElementById('mobile-menu-btn');
6161
const menu = document.getElementById('mobile-menu');
62-
if (!btn || !menu) return;
62+
const docsSidebar = document.getElementById('docs-sidebar-mobile');
63+
const overlay = document.getElementById('sidebar-overlay');
64+
if (!btn) return;
65+
6366
// Remove old listeners by cloning
6467
const newBtn = btn.cloneNode(true);
6568
btn.parentNode?.replaceChild(newBtn, btn);
66-
newBtn.addEventListener('click', () => menu.classList.toggle('hidden'));
69+
70+
newBtn.addEventListener('click', () => {
71+
if (docsSidebar && overlay) {
72+
// On docs pages, toggle the sidebar drawer instead of the dropdown
73+
const isOpen = !docsSidebar.classList.contains('-translate-x-full');
74+
if (isOpen) {
75+
docsSidebar.classList.add('-translate-x-full');
76+
overlay.classList.add('hidden');
77+
} else {
78+
docsSidebar.classList.remove('-translate-x-full');
79+
overlay.classList.remove('hidden');
80+
}
81+
// Keep dropdown hidden
82+
if (menu) menu.classList.add('hidden');
83+
} else if (menu) {
84+
menu.classList.toggle('hidden');
85+
}
86+
});
6787
}
6888
initNav();
6989
document.addEventListener('astro:after-swap', initNav);

site/src/layouts/Docs.astro

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,8 @@ const { prev, next } = getPrevNext(currentPath);
2424

2525
<Base title={`${title} - Mantle Docs`}>
2626
<Nav />
27-
<div class="mx-auto max-w-[1280px] px-4 sm:px-6">
27+
<div class="mx-auto max-w-[1280px] px-4 sm:px-6 overflow-x-hidden">
2828
<div class="flex min-h-screen pt-16">
29-
<!-- Mobile sidebar toggle -->
30-
<button
31-
id="sidebar-toggle"
32-
class="lg:hidden fixed bottom-6 left-6 z-50 flex items-center gap-2 px-4 py-2.5 bg-surface-container-high border border-outline-variant text-on-surface text-sm font-medium shadow-lg"
33-
aria-label="Toggle sidebar"
34-
>
35-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
36-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
37-
</svg>
38-
Menu
39-
</button>
40-
4129
<DocsSidebar currentPath={currentPath} />
4230

4331
<!-- Main content -->

site/src/styles/global.css

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,17 @@ body {
317317
margin-top: 0;
318318
}
319319

320-
/* Tables */
320+
/* Tables — horizontally scrollable on small screens */
321+
.prose .table-wrapper {
322+
overflow-x: auto;
323+
-webkit-overflow-scrolling: touch;
324+
margin-top: 1.5em;
325+
}
326+
327+
.prose .table-wrapper table {
328+
margin-top: 0;
329+
}
330+
321331
.prose table {
322332
width: 100%;
323333
border-collapse: collapse;
@@ -365,6 +375,30 @@ body {
365375
border: 1px solid var(--color-outline-variant);
366376
}
367377

378+
/* Mobile prose adjustments */
379+
@media (max-width: 640px) {
380+
.prose h1 {
381+
font-size: 1.5rem;
382+
}
383+
384+
.prose h2 {
385+
font-size: 1.25rem;
386+
}
387+
388+
.prose h3 {
389+
font-size: 1.1rem;
390+
}
391+
392+
.prose pre {
393+
font-size: 0.8125rem;
394+
padding: 0.75em 1em;
395+
}
396+
397+
.prose code {
398+
word-break: break-word;
399+
}
400+
}
401+
368402
/* Definition lists (used in some docs) */
369403
.prose dt {
370404
font-weight: 600;

0 commit comments

Comments
 (0)