mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-16 16:16:32 +03:00
Mobile collapsible sidebar + more breathing room on active state
Three docs sidebar improvements. 1. Collapsible mobile menu. The sidebar on narrow viewports used to dump 21 skill links and 2 tutorial links inline above the content, forcing a long scroll past the nav. Add a toggle button at the top of the sidebar that shows the current page label (e.g. "/overdrive" or "Getting started") plus a chevron, and collapses the menu behind it on mobile. Click the button to open/close. On desktop (>=920px) the toggle is hidden and the menu shows unconditionally as before. Pure aria-expanded state driven by a small delegated click handler in render-page.js. 2. Active-state breathing room. The left-border accent on the current sidebar item used to sit 2px from the text, which felt cramped. Pull the border 14px to the left via margin-left and push the text 12px to the right via padding-left. The net result: the accent bar sits in the layout gutter, the text keeps its alignment with the brand logo in the header, and there's now 12px of comfortable space between the border and the text. 3. Active state visibility. The same change makes the accent bar more visible on desktop, since it no longer hugs the text. 'aria-current' was already being set correctly on /skills/* and /tutorials/* pages; the bar just looked too subtle at 2px of clearance.
This commit is contained in:
@@ -155,9 +155,23 @@ ${bodyHtml}
|
||||
* null (no current page)
|
||||
*/
|
||||
function renderDocsSidebar(skillsByCategory, tutorials, current = null) {
|
||||
// Label the toggle button with the current page so mobile users know
|
||||
// where they are at a glance, then open the menu to switch.
|
||||
let currentLabel = 'Docs menu';
|
||||
if (current?.kind === 'skill') {
|
||||
currentLabel = `/${current.id}`;
|
||||
} else if (current?.kind === 'tutorial') {
|
||||
const t = tutorials.find((x) => x.slug === current.slug);
|
||||
if (t) currentLabel = t.title;
|
||||
}
|
||||
|
||||
let html = `
|
||||
<aside class="skills-sidebar" aria-label="Documentation">
|
||||
<div class="skills-sidebar-inner">
|
||||
<button class="skills-sidebar-toggle" type="button" aria-expanded="false" aria-controls="skills-sidebar-inner">
|
||||
<span class="skills-sidebar-toggle-label">${escapeHtml(currentLabel)}</span>
|
||||
<svg class="skills-sidebar-toggle-chevron" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>
|
||||
</button>
|
||||
<div class="skills-sidebar-inner" id="skills-sidebar-inner">
|
||||
<p class="skills-sidebar-label">Docs</p>
|
||||
`;
|
||||
|
||||
|
||||
@@ -115,6 +115,14 @@ ${bodyHtml}
|
||||
}).catch(() => {});
|
||||
});
|
||||
|
||||
// Mobile sidebar toggle (shown on narrow viewports, hidden on desktop).
|
||||
document.addEventListener('click', (e) => {
|
||||
const toggle = e.target.closest('.skills-sidebar-toggle');
|
||||
if (!toggle) return;
|
||||
const expanded = toggle.getAttribute('aria-expanded') === 'true';
|
||||
toggle.setAttribute('aria-expanded', String(!expanded));
|
||||
});
|
||||
|
||||
// Before/after split-compare: drag on touch, hover OR drag on mouse.
|
||||
// Pointer events attach to the padded .split-comparison wrapper so
|
||||
// there is a ~20px invisible buffer around the visible box. The
|
||||
|
||||
Reference in New Issue
Block a user