thp-lang.org/src/components/Navbar.astro

71 lines
2.1 KiB
Plaintext
Raw Normal View History

2024-04-23 21:25:10 +00:00
---
const { showSidebarButton = true } = Astro.props;
---
<nav
class="fixed w-full top-0 h-12 border-b border-[rgba(150,150,150,0.25)] bg-c-nav-bg backdrop-blur-md z-20"
>
2024-04-23 15:16:51 +00:00
<div class="container mx-auto h-full w-full flex items-center">
2024-04-23 21:25:10 +00:00
{
showSidebarButton && (
<button id="sidebar-toggle" class="w-10 h-full lg:hidden">
<i class="ph-bold ph-list text-xl inline-block" />
</button>
)
}
<a
href="/"
class="inline-block px-4 font-display font-black text-2xl hover:underline"
>
<img
class="inline-block h-10"
src="/img/thp_logo_exp.svg"
alt="thp"
/>
2024-04-23 15:16:51 +00:00
</a>
2024-04-23 21:25:10 +00:00
<a
href="/learn/"
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
>
2024-04-23 15:16:51 +00:00
Learn
</a>
2024-04-23 21:25:10 +00:00
<a
href="/how-to/"
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
>
2024-04-23 15:16:51 +00:00
How to guides
</a>
2024-04-23 21:25:10 +00:00
<a
href="/reference/"
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
>
2024-04-23 15:16:51 +00:00
Language reference
</a>
2024-04-23 21:25:10 +00:00
<a
href="/api/"
class="hidden lg:inline-block px-4 font-display font-bold-text-xl hover:underline"
>
2024-04-23 15:16:51 +00:00
Stdlib API
</a>
2024-04-23 21:25:10 +00:00
</div>
</nav>
<script>
document.addEventListener("DOMContentLoaded", () => {
const sidebar = document.getElementById("sidebar");
const sidebarToggle = document.getElementById("sidebar-toggle");
if (!sidebar || !sidebarToggle) {
console.log("Sidebar or Sidebar toggle not found. Not enabling sidebar on mobile");
return;
}
sidebarToggle.addEventListener("click", () => {
console.log(":D");
sidebar.classList.toggle("-translate-x-64");
console.log(sidebar.classList.contains("-translate-x-64"));
});
});
</script>