Skip to content

Commit 822b0d7

Browse files
committed
fix: correct top nav layout — display as separate row below header
The TopNav was being squeezed into the same row as the logo/search because PageFrame's header had a fixed height constraint. Fix: - Added --sl-top-nav-height and --sl-header-total-height CSS variables - PageFrame header now uses flex-direction: column on desktop to stack the header content and TopNav vertically - Sidebar and main-frame positioning use --sl-header-total-height on desktop so they offset correctly below both header rows - Header.astro inner content takes --sl-nav-height height, TopNav fills the remaining --sl-top-nav-height space
1 parent e1e2cd6 commit 822b0d7

File tree

3 files changed

+44
-26
lines changed

3 files changed

+44
-26
lines changed

src/starlight-overrides/Header.astro

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,20 @@ const shouldRenderSearch =
1818
config.pagefind || config.components.Search !== "@astrojs/starlight/components/Search.astro";
1919
---
2020

21-
<div class="header-row">
22-
<div class="header">
23-
<div class="title-wrapper sl-flex">
24-
<SiteTitle />
25-
</div>
26-
<div class="sl-flex print:hidden">
27-
{shouldRenderSearch && <Search />}
28-
</div>
29-
<div class="sl-hidden md:sl-flex print:hidden right-group">
30-
<div class="sl-flex social-icons">
31-
<SocialIcons />
32-
</div>
33-
<ThemeSelect />
34-
<LanguageSelect />
35-
<ChatButton />
21+
<div class="header-inner">
22+
<div class="title-wrapper sl-flex">
23+
<SiteTitle />
24+
</div>
25+
<div class="sl-flex print:hidden">
26+
{shouldRenderSearch && <Search />}
27+
</div>
28+
<div class="sl-hidden md:sl-flex print:hidden right-group">
29+
<div class="sl-flex social-icons">
30+
<SocialIcons />
3631
</div>
32+
<ThemeSelect />
33+
<LanguageSelect />
34+
<ChatButton />
3735
</div>
3836
</div>
3937

@@ -45,16 +43,13 @@ const shouldRenderSearch =
4543

4644
<style>
4745
@layer starlight.core {
48-
.header-row {
49-
/* The header row itself — no changes needed */
50-
}
51-
52-
.header {
46+
.header-inner {
5347
display: flex;
5448
gap: var(--sl-nav-gap);
5549
justify-content: space-between;
5650
align-items: center;
57-
height: 100%;
51+
height: var(--sl-nav-height);
52+
flex-shrink: 0;
5853
}
5954

6055
.title-wrapper {
@@ -78,7 +73,6 @@ const shouldRenderSearch =
7873
.top-nav-row {
7974
border-top: 1px solid var(--sl-color-hairline-shade);
8075
margin: 0 calc(-1 * var(--sl-nav-pad-x));
81-
margin-bottom: calc(-1 * var(--sl-nav-pad-y));
8276
}
8377

8478
@media (min-width: 50rem) {
@@ -88,7 +82,7 @@ const shouldRenderSearch =
8882
:global(:root:not([data-has-toc])) {
8983
--__toc-width: 0rem;
9084
}
91-
.header {
85+
.header-inner {
9286
--__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
9387
--__main-column-fr: calc(
9488
(

src/starlight-overrides/PageFrame.astro

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,25 @@ const { hasSidebar } = Astro.locals.starlightRoute;
5555
);
5656
}
5757

58+
@media (min-width: 50rem) {
59+
.header {
60+
display: flex;
61+
flex-direction: column;
62+
height: var(--sl-header-total-height, var(--sl-nav-height));
63+
padding-bottom: 0;
64+
}
65+
}
66+
5867
.sidebar-pane {
5968
visibility: var(--sl-sidebar-visibility, hidden);
6069
position: fixed;
61-
height: calc(100dvh - var(--sl-nav-height));
6270
z-index: var(--sl-z-index-menu);
6371
inset-inline-start: 0;
6472
width: 100%;
6573
background-color: var(--sl-color-black);
6674
overflow-y: auto;
6775
top: var(--sl-nav-height);
76+
height: calc(100dvh - var(--sl-nav-height));
6877
}
6978

7079
:global([aria-expanded="true"]) ~ .sidebar-pane {
@@ -102,15 +111,22 @@ const { hasSidebar } = Astro.locals.starlightRoute;
102111
background-color: var(--sl-color-bg-sidebar);
103112
border-inline-end: 1px solid var(--sl-color-hairline-shade);
104113
position: sticky;
114+
top: var(--sl-header-total-height, var(--sl-nav-height));
115+
height: calc(100dvh - var(--sl-header-total-height, var(--sl-nav-height)));
116+
}
117+
.main-frame {
118+
padding-top: calc(
119+
var(--sl-header-total-height, var(--sl-nav-height)) + var(--sl-mobile-toc-height)
120+
);
105121
}
106122
}
123+
107124
.global-footer {
108-
display: block;
125+
display: flex;
109126
width: 100%;
110127
border-top: 1px solid var(--sl-color-hairline);
111128
text-align: center;
112129
padding: 2rem 0;
113-
display: flex;
114130
justify-content: center;
115131
align-items: center;
116132
gap: 1rem;

src/styles/global.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
}
1515
}
1616

17+
/* Top navigation bar height (desktop only) */
18+
@media (min-width: 50rem) {
19+
:root {
20+
--sl-top-nav-height: 2.75rem;
21+
--sl-header-total-height: calc(var(--sl-nav-height) + var(--sl-top-nav-height));
22+
}
23+
}
24+
1725
/* Chat Widget Styles */
1826
:root {
1927
--chat-header-height: 3.5rem;

0 commit comments

Comments
 (0)