feat: Main page cover

This commit is contained in:
Leni Aniva 2024-09-13 17:00:03 -07:00
parent f0801b9071
commit 63ac9eadd8
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
3 changed files with 109 additions and 17 deletions

View File

@ -1,22 +1,27 @@
<script lang="ts"> <script lang="ts">
import '../app.css'; import '../app.css';
import { page } from '$app/stores';
import { Separator } from "$lib/components/ui/separator/index.js"; import { Separator } from "$lib/components/ui/separator/index.js";
import { routes } from "./sitemap.ts"
const routes: { route: string, name: string }[] = [
{ route: "/", name: "Home" },
{ route: "/post", name: "Blog" },
{ route: "/about", name: "About" },
];
</script> </script>
<div> <!-- Homepage has its own navbar with animations -->
{#if $page.url.pathname != "/"}
<div>
<div class="flex h-5 items-center space-x-4 text-sm"> <div class="flex h-5 items-center space-x-4 text-sm">
{#each routes as item, i} {#each routes as item, i}
{#if i > 0} {#if i > 0}
<Separator orientation="vertical" /> <Separator orientation="vertical" />
{/if} {/if}
<a href={item.route}>{item.name}</a> <a class:active-link={item.route === $page.url.pathname} href={item.route}>{item.name}</a>
{/each} {/each}
</div> </div>
</div> </div>
{/if}
<slot /> <slot />
<style>
.active-link {
@apply text-emerald-300;
}
</style>

View File

@ -1,2 +1,84 @@
<h1>Home Page</h1> <script lang="ts">
<p>This is the home page</p> import { routes } from "./sitemap.ts"
import { Separator } from "$lib/components/ui/separator/index.js";
let scrollPosition: number = .5;
let scrollHeight: number = 1;
let progress: number = 0;
function onScroll(p) {
if (scrollHeight > 1) {
progress = Math.min(1, scrollPosition / scrollHeight);
}
}
</script>
<div
id="background"
style="opacity: {1 - progress}"
>
</div>
<div id="front">
<div id="floater">
<p class="floater-elem" style="color: #888">This is a very long description</p>
<div
class="floater-elem"
style="padding-bottom: {(1 - progress) * 50}vh"
>
<div class="flex h-5 items-center space-x-4 text-sm">
<a href="#bio">Bio</a>
{#each routes as item}
{#if item.route !== "/"}
<Separator orientation="vertical" />
<a href={item.route}>{item.name}</a>
{/if}
{/each}
</div>
</div>
</div>
</div>
<div id="bio" class="bg-white dark:bg-gray-900" style="">
<h1>Home Page</h1>
<p>This is the home page. You have scrolled {scrollPosition} / {scrollHeight}, progress: {progress}</p>
</div>
<svelte:window
bind:scrollY={scrollPosition}
bind:innerHeight={scrollHeight}
on:scroll={onScroll}
/>
<style>
#background {
background-image: url('/favicon.svg');
background-attachment: fixed;
background-size: 100%;
background-position: center;
z-index: -10;
position: absolute;
min-width: 100vw;
min-height: 100vh;
}
#bio {
width: 100vw;
min-height: 100vh;
}
#front {
height: 100vh;
display: flex;
flex-direction: column;
}
#floater {
display: flex;
flex-direction: column;
justify-content: center;
margin-top: auto;
margin-left: auto;
margin-right: auto;
}
.floater-elem {
margin-left: auto;
margin-right: auto;
}
</style>

5
src/routes/sitemap.ts Normal file
View File

@ -0,0 +1,5 @@
export const routes: { route: string, name: string }[] = [
{ route: "/", name: "Home" },
{ route: "/post", name: "Blog" },
{ route: "/about", name: "About" },
];