Skip to content

Commit 5b244be

Browse files
authored
Merge pull request #70 from zerodevapp/fix/pillar-bar-mobile-desktop
fix(pillar-bar): stop sidebar clip on desktop and overlap on mobile
2 parents 9c2aecf + 1ed9325 commit 5b244be

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

vocs.config.tsx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,9 @@ export default defineConfig({
13011301
margin-top: var(--zd-pillar-bar-height);
13021302
}
13031303
1304-
/* Pillar bar: fixed horizontal nav directly below the top header.
1305-
Mounted at document.body so it escapes the fixed-height gutterTop. */
1304+
/* Pillar bar: horizontal nav directly below the top header. Inserted in-flow
1305+
right after Vocs's gutterTop; pinned fixed on desktop (below), in-flow on
1306+
mobile (see media query). */
13061307
.zd-pillar-bar {
13071308
position: fixed;
13081309
top: var(--vocs-topNav_height, 56px);
@@ -1313,13 +1314,16 @@ export default defineConfig({
13131314
align-items: center;
13141315
gap: 4px;
13151316
height: var(--zd-pillar-bar-height);
1316-
/* Match Vocs's leftGutterWidth calc — that variable is scoped to
1317-
.vocs_DocsLayout so it's not visible on body. Recompute it here using
1318-
:root-scoped vars so the bar's content aligns with the search bar. */
1319-
padding-left: max(
1317+
/* Start the bar AFTER the sidebar gutter instead of spanning full width.
1318+
Vocs's leftGutterWidth var is scoped to .vocs_DocsLayout (not visible on
1319+
body), so recompute the same max() here. Anchoring left to it keeps the
1320+
bar from overlapping the fixed sidebar (gutterLeft, z-index 14) — the
1321+
pillar bar's z-index 50 would otherwise paint over the sidebar's top. */
1322+
left: max(
13201323
calc((100vw - var(--vocs-content_width)) / 2),
13211324
var(--vocs-sidebar_width)
13221325
);
1326+
padding-left: 0;
13231327
padding-right: 24px;
13241328
border-bottom: 1px solid var(--vocs-color_border);
13251329
background: var(--vocs-color_background);
@@ -1349,12 +1353,21 @@ export default defineConfig({
13491353
background: var(--vocs-color_backgroundIrisTint);
13501354
}
13511355
1352-
/* On narrow viewports, Vocs hides the desktop top nav and shows a mobile drawer.
1353-
Hide the pillar bar there too — Vocs's mobile menu will surface pillar links via
1354-
the sidebar. */
1356+
/* On narrow viewports Vocs makes the top nav position:initial (in normal flow)
1357+
and shows a sticky section curtain below it. The bar is inserted in-flow
1358+
right after the top nav, so drop the fixed positioning and let it stack
1359+
naturally — a fixed bar would float over and hide that curtain. No sidebar
1360+
gutter here either, so span full width. */
13551361
@media (max-width: 1080px) {
1356-
.zd-pillar-bar { display: none; }
1357-
.vocs_DocsLayout_content { padding-top: var(--vocs-topNav_height, 56px) !important; }
1362+
.zd-pillar-bar {
1363+
position: static;
1364+
padding-left: 8px;
1365+
/* Match the mobile top nav / curtain background (both use backgroundDark). */
1366+
background: var(--vocs-color_backgroundDark);
1367+
}
1368+
/* Top nav is in-flow on mobile, so content needs no extra top padding;
1369+
the in-flow bar already occupies its own space. */
1370+
.vocs_DocsLayout_content { padding-top: 0 !important; }
13581371
.vocs_DocsLayout_gutterRight { margin-top: 0; }
13591372
}
13601373
</style>`;
@@ -1402,11 +1415,16 @@ export default defineConfig({
14021415
14031416
function mount() {
14041417
if (document.getElementById('zd-pillar-bar')) return;
1405-
if (!document.body) return;
1418+
// Insert as a sibling right after Vocs's top-nav container so the bar lives
1419+
// in normal document flow. On desktop (>=1081px) the CSS pins it with
1420+
// position:fixed (DOM position irrelevant). On mobile (<=1080px) Vocs makes
1421+
// the top nav position:initial (in-flow) and shows a sticky section curtain;
1422+
// an in-flow bar here sits correctly below the nav instead of a fixed bar
1423+
// floating over and hiding that curtain.
1424+
var gutterTop = document.querySelector('.vocs_DocsLayout_gutterTop');
1425+
if (!gutterTop || !gutterTop.parentNode) return;
14061426
var bar = build();
1407-
// Mount at body level so it escapes Vocs's fixed-height gutterTop container.
1408-
// The CSS pins it via position:fixed below the existing top nav.
1409-
document.body.appendChild(bar);
1427+
gutterTop.parentNode.insertBefore(bar, gutterTop.nextSibling);
14101428
updateActive();
14111429
}
14121430

0 commit comments

Comments
 (0)