Skip to content

Commit 8f8d7cd

Browse files
authored
docs: Add mobile top navigation (#18)
1 parent 984d66c commit 8f8d7cd

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/components/Header.astro

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ const navItems = [
2222
<div class="title-wrapper sl-flex">
2323
<SiteTitle {...Astro.props} />
2424
</div>
25+
<nav class="mobile-site-nav md:sl-hidden" aria-label="Main">
26+
{navItems.map(({ label, href, active }) => (
27+
<a href={href} class:list={['nav-link', 'mobile-nav-link', { active }]}>{label}</a>
28+
))}
29+
</nav>
2530
<nav class="site-nav sl-hidden md:sl-flex" aria-label="Main">
2631
{navItems.map(({ label, href, active }) => (
2732
<a href={href} class:list={['nav-link', { active }]}>{label}</a>
2833
))}
2934
</nav>
30-
<div class="search-wrapper sl-flex print:hidden">
35+
<div class="search-wrapper sl-hidden md:sl-flex print:hidden">
3136
{shouldRenderSearch && <Search {...Astro.props} />}
3237
</div>
3338
<div class="right-group sl-hidden md:sl-flex print:hidden">
@@ -60,6 +65,22 @@ const navItems = [
6065
align-items: center;
6166
}
6267

68+
.mobile-site-nav {
69+
display: flex;
70+
flex: 1;
71+
min-width: 0;
72+
gap: 0.35rem;
73+
align-items: center;
74+
overflow-x: auto;
75+
padding-inline-end: 0.15rem;
76+
scrollbar-width: none;
77+
-ms-overflow-style: none;
78+
}
79+
80+
.mobile-site-nav::-webkit-scrollbar {
81+
display: none;
82+
}
83+
6384
/* Search takes remaining space but is capped so right-group goes to far right */
6485
.search-wrapper {
6586
flex: 1;
@@ -98,6 +119,12 @@ const navItems = [
98119
transition: background-color 0.15s, color 0.15s;
99120
}
100121

122+
.mobile-nav-link {
123+
flex-shrink: 0;
124+
font-size: 0.82rem;
125+
padding: 0.3rem 0.62rem;
126+
}
127+
101128
.nav-link:hover,
102129
.nav-link.active {
103130
background-color: rgba(255, 255, 255, 0.18);

0 commit comments

Comments
 (0)