Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions docs/src/pages/docs/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const docsBase = Astro.site
</div>
</div>

{requestedSlug && <script is:inline define:vars={{ slug: requestedSlug, isRoot: isRoot }}>window.__docsSlug = slug; window.__isRoot = isRoot;</script>}

<script is:inline define:vars={{ isRoot, docsBase }}>
document.addEventListener('DOMContentLoaded', function () {
const sections = document.querySelectorAll('section.doc-section');
Expand All @@ -132,6 +134,7 @@ const docsBase = Astro.site
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('overlay');
const searchBox = document.getElementById('searchBox');
const isRoot = window.__isRoot !== false;
const prefersReducedMotion = !window.matchMedia('(prefers-reduced-motion: no-preference)').matches;

/* Mobile menu toggle */
Expand All @@ -147,37 +150,52 @@ const docsBase = Astro.site
menuToggle.setAttribute('aria-expanded', String(isOpen));
});
overlay.addEventListener('click', closeMenu);
navItems.forEach(function (item) {
item.addEventListener('click', closeMenu);
});
}

/* Auto-scroll to hash section (root only) */
if (isRoot && window.location.hash) {
const targetId = window.location.hash.slice(1);
const target = document.getElementById(targetId);
if (target) {
setTimeout(function () {
target.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth' });
}, 100);
/* Auto-scroll to section (root only) */
if (isRoot) {
const targetSlug = window.__docsSlug;
const hash = window.location.hash;
const sectionId = targetSlug || (hash && hash.length > 1 ? hash.slice(1) : null);
if (sectionId) {
const target = document.getElementById(sectionId);
if (target) {
setTimeout(function () {
target.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth' });
}, 100);
}
}
}

/* Scrollspy (root + multi-section only) */
/* Scrollspy + nav click (root + multi-section only) */
if (isRoot && sections.length > 1) {
const observer = new IntersectionObserver(
function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
navItems.forEach(function (item) {
item.classList.toggle('active', item.getAttribute('data-nav-id') === entry.target.id);
var isActive = item.getAttribute('data-nav-id') === entry.target.id;
item.classList.toggle('active', isActive);
if (isActive) {
item.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth', block: 'nearest' });
}
});
}
});
},
{ root: null, rootMargin: '-80px 0px -60% 0px', threshold: 0 }
);
sections.forEach(function (section) { observer.observe(section); });

navItems.forEach(function (item) {
item.addEventListener('click', function () {
if (window.innerWidth <= 768 && menuToggle && sidebar && overlay) {
sidebar.classList.remove('open');
overlay.classList.remove('open');
menuToggle.setAttribute('aria-expanded', 'false');
}
});
});
}

/* Search filter (root only) */
Expand Down
43 changes: 43 additions & 0 deletions docs/src/styles/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,49 @@
z-index: 95;
}

/* ── Scroll behavior / reduced motion ──────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0s !important;
animation-iteration-count: 1 !important;
transition-duration: 0s !important;
}
}

/* ── Custom scrollbar ─────────────────────────────────────────────── */
html {
scrollbar-color: var(--rust-orange) var(--bg-deep);
scrollbar-width: thin;
}

::-webkit-scrollbar {
width: 6px;
height: 6px;
}

::-webkit-scrollbar-track {
background: var(--bg-deep);
border-left: 1px solid rgba(45, 26, 0, 0.5);
}

::-webkit-scrollbar-thumb {
background: var(--rust-orange);
border-radius: 3px;
transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
background: #DEA584;
}

::-webkit-scrollbar-corner {
background: var(--bg-deep);
}

/* ── Scrollbar (docs sidebar) ──────────────────────────────────────── */
.docs-layout .sidebar::-webkit-scrollbar {
width: 4px;
Expand Down
Loading