Skip to content

Commit bda15bf

Browse files
committed
Fix UI glitches regarding Header regarding background
also prevent scrolling horizontally on the body tag for empty space
1 parent 3025300 commit bda15bf

File tree

3 files changed

+43
-34
lines changed

3 files changed

+43
-34
lines changed

src/components/app/Header.astro

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,48 @@
22
import HeaderLink from './HeaderLink.astro';
33
import LinkToHome from './LinkToHome.astro';
44
5-
const { fillBg } = Astro.props;
5+
const { sticky } = Astro.props;
66
---
77

8-
<div
9-
class:list={[
10-
'py-3',
11-
'flex',
12-
'flex-row',
13-
'items-center',
14-
'lg:ml--48',
15-
'xl:ml--60',
16-
{ 'bg-white': fillBg },
17-
]}
18-
>
19-
<div class="w-48 xl:w-60">
20-
<LinkToHome />
21-
</div>
22-
<div class="mx-3 lg:hidden"></div>
23-
<nav>
24-
<section class="">
8+
<>
9+
{
10+
sticky && (
11+
// "background" that spans from end to end horizontally
12+
<div class="absolute top-0 left-0 w-full z-20">
13+
<div class="fixed h-13 bg-white/90 w-full" />
14+
</div>
15+
)
16+
}
17+
<!-- actual header -->
18+
<header
19+
class:list={[
20+
'py-3',
21+
'flex',
22+
'flex-row',
23+
'items-center',
24+
'lg:ml--48',
25+
'xl:ml--60',
26+
{ sticky: sticky },
27+
{ 'top-0': sticky },
28+
{ 'z-20': sticky },
29+
]}
30+
>
31+
<nav class="w-48 xl:w-60">
32+
<LinkToHome />
33+
</nav>
34+
<div class="mx-3 lg:mx-1"></div>
35+
<nav>
2536
<ul class="unset flex gap-4 [&>li]:p-0">
2637
<li><HeaderLink href="/toys">Toys</HeaderLink></li>
2738
<li><HeaderLink href="/posts">Posts</HeaderLink></li>
2839
</ul>
29-
</section>
30-
</nav>
31-
<div class="flex-grow"></div>
32-
<a
33-
href="https://github.com/bizarre-binary/bizarre-binary.github.io"
34-
aria-label="Open the repo on GitHub"
35-
>
36-
<div class="i-bi-git text-yellow-400 text-xl"></div>
37-
</a>
38-
</div>
40+
</nav>
41+
<div class="flex-grow"></div>
42+
<a
43+
href="https://github.com/bizarre-binary/bizarre-binary.github.io"
44+
aria-label="Open the repo on GitHub"
45+
>
46+
<div class="i-bi-git text-yellow-400 text-xl"></div>
47+
</a>
48+
</header>
49+
</>

src/components/app/SideNavs.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const pathMatchesUrl = (url: string) => {
2525
<LinkToHome />
2626
</header>
2727
<!-- safe list class="text-gray-800" -->
28-
<div class="px-3">
28+
<nav class="px-3">
2929
<h2 class="mt-10 my-2 font-bold text-gray-500">Toys</h2>
3030
<ul class="text-sm">
3131
{
@@ -38,7 +38,7 @@ const pathMatchesUrl = (url: string) => {
3838
))
3939
}
4040
</ul>
41-
</div>
41+
</nav>
4242
</div>
4343
</div>
4444
<!-- place holder to represent the actual content-->

src/layouts/Layout.astro

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ const description = titleFromProps ? `${defaultTitle} - ${title}` : title;
3232
<GlobalStyle />
3333
<PWA />
3434
</head>
35-
<body class="m-auto max-w-prose px-2 md:px-0 flex flex-col [min-height:100svh]">
36-
<header class="sticky z-20 top-0">
37-
<Header fillBg={true} />
38-
</header>
35+
<body class="m-auto max-w-prose px-2 md:px-0 flex flex-col [min-height:100svh] overflow-x-hidden">
36+
<Header sticky={true} />
3937
<SideNavs />
4038
<main>
4139
<slot />

0 commit comments

Comments
 (0)