Files
blitzkit/packages/website-ue/src/components/Navbar.astro
T

141 lines
2.8 KiB
Plaintext
Raw Normal View History

2026-01-12 13:46:58 -06:00
---
import { BlitzKitIcon } from "../icons/BlitzKit";
2026-01-13 20:33:14 -06:00
import { LinkI18n } from "./LinkI18n";
2026-01-25 15:55:30 -06:00
import { HamburgerMenuIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
2026-01-13 20:33:14 -06:00
interface Props {
locale: string;
}
2026-01-25 15:55:30 -06:00
const { locale } = Astro.props;
2026-01-12 13:46:58 -06:00
---
<style>
2026-01-15 13:48:37 -06:00
#navbar {
2026-01-25 15:55:30 -06:00
position: sticky;
top: 0;
2026-01-13 20:33:14 -06:00
left: 0;
2026-01-18 15:14:26 -06:00
width: 100%;
2026-01-12 13:46:58 -06:00
display: flex;
2026-01-25 15:55:30 -06:00
justify-content: center;
2026-01-12 13:46:58 -06:00
z-index: 1;
2026-01-25 15:55:30 -06:00
background-color: var(--gray-a2);
2026-01-15 13:48:37 -06:00
box-shadow: var(--shadow-none);
2026-01-25 15:55:30 -06:00
backdrop-filter: var(--blur-glass) brightness(10%);
box-shadow: var(--shadow-subtle);
2026-01-15 13:48:37 -06:00
transition-duration: var(--duration-brief);
&[data-sticky="true"] {
2026-01-25 15:55:30 -06:00
transform: translateY(-100%);
box-shadow: var(--shadow-none);
2026-01-15 13:48:37 -06:00
}
2026-01-13 20:33:14 -06:00
.content {
2026-01-25 15:55:30 -06:00
display: flex;
justify-content: space-between;
2026-01-18 15:14:26 -06:00
width: 100%;
2026-01-13 20:33:14 -06:00
max-width: calc(var(--page-width) + 2 * var(--space-4));
2026-01-12 13:46:58 -06:00
2026-01-25 15:55:30 -06:00
.group {
2026-01-12 13:46:58 -06:00
display: flex;
2026-01-18 14:51:55 -06:00
gap: var(--space-2);
2026-01-12 13:46:58 -06:00
2026-01-25 15:55:30 -06:00
.action {
display: flex;
flex-direction: column;
align-items: center;
padding: var(--space-3);
gap: var(--space-2);
2026-01-13 20:33:14 -06:00
2026-01-25 15:55:30 -06:00
cursor: pointer;
text-decoration: none;
2026-01-13 20:33:14 -06:00
2026-01-18 14:51:55 -06:00
.selector {
2026-01-25 15:55:30 -06:00
padding: var(--space-2);
border-radius: var(--max-size);
2026-01-13 20:33:14 -06:00
2026-01-25 15:55:30 -06:00
display: flex;
justify-content: center;
2026-01-18 14:51:55 -06:00
2026-01-18 18:38:26 -06:00
width: 100%;
2026-01-25 15:55:30 -06:00
max-width: var(--space-6);
2026-01-18 14:51:55 -06:00
2026-01-25 15:55:30 -06:00
.icon {
height: 1.25em;
width: 100%;
vertical-align: top;
}
}
2026-01-18 14:51:55 -06:00
}
2026-01-12 13:46:58 -06:00
}
}
}
</style>
2026-01-15 13:48:37 -06:00
<script>
const navbar = document.getElementById("navbar")!;
2026-01-18 15:14:26 -06:00
let lastScrollY = window.scrollY;
2026-01-15 13:48:37 -06:00
function handleScroll() {
2026-01-18 15:14:26 -06:00
const dy = window.scrollY - lastScrollY;
lastScrollY = window.scrollY;
2026-01-25 15:55:30 -06:00
const hide = window.scrollY > navbar.clientHeight && dy > 0;
navbar.dataset.sticky = `${hide}`;
2026-01-15 13:48:37 -06:00
}
handleScroll();
window.addEventListener("scroll", handleScroll);
</script>
<div id="navbar">
2026-01-13 20:33:14 -06:00
<div class="content">
2026-01-25 15:55:30 -06:00
<div class="group">
2026-01-31 23:21:43 -06:00
<LinkI18n
color="gray"
highContrast
{locale}
href="/"
className="action"
tabIndex={0}
>
2026-01-25 15:55:30 -06:00
<div class="selector">
<BlitzKitIcon className="icon" />
</div>
</LinkI18n>
</div>
2026-01-13 20:33:14 -06:00
2026-01-25 15:55:30 -06:00
<div class="group">
2026-01-31 23:21:43 -06:00
<LinkI18n
color="gray"
highContrast
{locale}
href="/"
className="action"
tabIndex={0}
>
2026-01-25 15:55:30 -06:00
<div class="selector">
<MagnifyingGlassIcon className="icon" />
</div>
</LinkI18n>
2026-01-18 17:55:38 -06:00
2026-01-31 23:21:43 -06:00
<LinkI18n
color="gray"
highContrast
{locale}
href="/"
className="action"
tabIndex={0}
>
2026-01-25 15:55:30 -06:00
<div class="selector">
<HamburgerMenuIcon className="icon" />
</div>
</LinkI18n>
</div>
2026-01-12 13:46:58 -06:00
</div>
</div>