Make navbar not fixed

This commit is contained in:
Mikkel Svartveit 2024-09-18 15:30:10 +02:00
parent 51b6432f79
commit dbbf4d32d2
4 changed files with 3 additions and 19 deletions

View file

@ -1,13 +1,9 @@
<script lang="ts">
import { slide, fade } from "svelte/transition";
export let sticky = true;
export let currentPath: string;
$: currentPathTrimmed = currentPath.replace(/\/+$/, "");
let scrollPosition = 0;
$: isScrolled = scrollPosition > 0;
const navbarContent = [
{ name: "📝 Articles", href: "/articles" },
{ name: "👨‍💻 Projects", href: "/programming" },
@ -17,12 +13,7 @@
let collapsed = true;
</script>
<svelte:window bind:scrollY={scrollPosition} />
<header
class={sticky ? "sticky top-0 z-10 bg-gray-50 transition-shadow ease-in" : ""}
class:shadow={sticky && isScrolled}
>
<header>
<nav
class="mx-auto flex h-16 max-w-5xl flex-wrap items-center justify-between px-6"
>

View file

@ -1,12 +1,6 @@
---
import Navbar from "@components/Navbar.svelte";
import HeadContent from "@components/HeadContent.astro";
interface Props {
noStickyNavbar?: boolean;
}
const { noStickyNavbar } = Astro.props;
---
<html lang="en">
@ -19,7 +13,6 @@ const { noStickyNavbar } = Astro.props;
<body class="overflow-y-scroll bg-gray-50">
<Navbar
client:load
sticky={!noStickyNavbar}
currentPath={Astro.url.pathname}
/>

View file

@ -18,7 +18,7 @@ const latestArticleImage = latestArticle.data.image;
<BaseLayout>
<div
class="mx-auto flex max-w-5xl flex-col-reverse items-stretch px-4 pb-6 pt-8 sm:px-6 md:flex-row"
class="mx-auto flex max-w-5xl flex-col-reverse items-stretch px-4 pb-6 pt-12 sm:px-6 md:flex-row"
>
<section class="mb-10 mt-4 w-full md:w-3/5">
<h1

View file

@ -22,7 +22,7 @@ export const getFileNameFromPath = (path: string) => {
};
---
<BaseLayout noStickyNavbar>
<BaseLayout>
<HeadContent slot="head" title="Photography" />
<ContainerLayout>