Navbars are still messed up

This commit is contained in:
Eclypsed
2024-01-27 01:38:04 -05:00
parent 1209b6ac25
commit bee4c903ec
15 changed files with 380 additions and 103 deletions

View File

@@ -1,11 +1,12 @@
<script lang="ts">
import { fly, fade } from 'svelte/transition'
import { fly } from 'svelte/transition'
import { goto } from '$app/navigation'
import { pageWidth } from '$lib/stores'
import type { LayoutServerData } from '../$types'
import NavbarSide, { type NavTab } from '$lib/components/util/navbarSide.svelte'
import NavbarFoot from '$lib/components/util/navbarFoot.svelte'
import { page } from '$app/stores'
export let data: LayoutServerData
let currentPathname = $page.url.pathname
const contentTabs: NavTab[] = [
{
@@ -33,111 +34,65 @@
const pageTransitionTime: number = 200
type PageTransitionDirection = 1 | -1
let direction: PageTransitionDirection = 1
// $: calculateDirection(data.urlPathname)
// const calculateDirection = (newPage: string): void => {
// const newPageIndex = contentTabs.findIndex((tab) => tab.pathname === newPage)
// const previousPageIndex = contentTabs.findIndex((tab) => tab.pathname === previousPage)
// newPageIndex > previousPageIndex ? (direction = 1) : (direction = -1)
// previousPage = data.urlPathname
// }
// let activeTab: HTMLButtonElement, indicatorBar: HTMLDivElement, tabList: HTMLDivElement
// $: calculateBar(activeTab)
// const calculateBar = (activeTab: HTMLButtonElement) => {
// if (activeTab && indicatorBar && tabList) {
// if ($pageWidth >= 768) {
// const listRect = tabList.getBoundingClientRect()
// const tabRec = activeTab.getBoundingClientRect()
// if (direction === 1) {
// indicatorBar.style.bottom = `${listRect.bottom - tabRec.bottom}px`
// setTimeout(() => (indicatorBar.style.top = `${tabRec.top - listRect.top}px`), pageTransitionTime)
// } else {
// indicatorBar.style.top = `${tabRec.top - listRect.top}px`
// setTimeout(() => (indicatorBar.style.bottom = `${listRect.bottom - tabRec.bottom}px`), pageTransitionTime)
// }
// } else {
// const listRect = tabList.getBoundingClientRect()
// const tabRec = activeTab.getBoundingClientRect()
// if (direction === 1) {
// indicatorBar.style.right = `${listRect.right - tabRec.right}px`
// setTimeout(() => (indicatorBar.style.left = `${tabRec.left - listRect.left}px`), pageTransitionTime)
// } else {
// indicatorBar.style.left = `${tabRec.left - listRect.left}px`
// setTimeout(() => (indicatorBar.style.right = `${listRect.right - tabRec.right}px`), pageTransitionTime)
// }
// }
// }
// }
let directionMultiplier: PageTransitionDirection = 1
</script>
<!-- {#if $pageWidth >= 768} -->
<div id="content-grid" class="h-full overflow-hidden">
<NavbarSide
navTabs={contentTabs}
currentPathname={data.urlPathname}
transitionTime={pageTransitionTime}
on:navigate={(event) => {
event.detail.direction === 'up' ? (direction = 1) : (direction = -1)
goto(event.detail.pathname)
}}
/>
<section class="no-scrollbar relative overflow-y-scroll">
{#key data.urlPathname}
<div in:fly={{ y: -50 * direction, duration: pageTransitionTime, delay: pageTransitionTime }} out:fly={{ y: 50 * direction, duration: pageTransitionTime }} class="absolute w-full pr-[5vw] pt-16">
<slot />
</div>
{/key}
</section>
<footer class="fixed bottom-0 flex w-full flex-col items-center justify-center">
<!-- <MiniPlayer displayMode={'horizontal'} /> -->
</footer>
</div>
<!-- {:else}
{#if $pageWidth >= 768}
<div id="content-grid" class="grid h-full grid-rows-1 gap-8 overflow-hidden">
<NavbarSide
navTabs={contentTabs}
{currentPathname}
transitionTime={pageTransitionTime}
on:navigate={(event) => {
event.detail.direction === 'up' ? (directionMultiplier = 1) : (directionMultiplier = -1)
currentPathname = event.detail.pathname
goto(currentPathname)
}}
/>
<section class="no-scrollbar relative overflow-y-scroll">
{#key currentPathname}
<div
in:fly={{ y: -50 * directionMultiplier, duration: pageTransitionTime, delay: pageTransitionTime }}
out:fly={{ y: 50 * directionMultiplier, duration: pageTransitionTime }}
class="absolute w-full pr-[5vw] pt-16"
>
<slot />
</div>
{/key}
</section>
<footer class="fixed bottom-0 flex w-full flex-col items-center justify-center">
<!-- <MiniPlayer displayMode={'horizontal'} /> -->
</footer>
</div>
{:else}
<div class="h-full overflow-hidden">
{#key data.urlPathname}
{#key currentPathname}
<section
in:fly={{ x: 200 * direction, duration: pageTransitionTime, delay: pageTransitionTime }}
out:fly={{ x: -200 * direction, duration: pageTransitionTime }}
in:fly={{ x: 200 * directionMultiplier, duration: pageTransitionTime, delay: pageTransitionTime }}
out:fly={{ x: -200 * directionMultiplier, duration: pageTransitionTime }}
class="no-scrollbar h-full overflow-y-scroll px-[5vw] pt-16"
>
<slot />
</section>
{/key}
<footer class="fixed bottom-0 flex w-full flex-col items-center justify-center">
<MiniPlayer displayMode={'vertical'} />
<div bind:this={tabList} id="bottom-tab-list" class="relative flex w-full items-center justify-around bg-black">
{#each contentTabs as tabData}
{#if data.urlPathname === tabData.pathname}
<button bind:this={activeTab} class="pointer-events-none text-white transition-colors" disabled>
<i class={tabData.icon} />
</button>
{:else}
<button class="text-neutral-400 transition-colors hover:text-lazuli-primary" on:click={() => goto(tabData.pathname)}>
<i class={tabData.icon} />
</button>
{/if}
{/each}
{#if contentTabs.some((tab) => tab.pathname === data.urlPathname)}
<div bind:this={indicatorBar} transition:fade class="absolute bottom-0 h-1 rounded-full bg-white transition-all duration-300 ease-in-out" />
{/if}
</div>
<!-- <MiniPlayer displayMode={'vertical'} /> -->
<NavbarFoot
navTabs={contentTabs}
{currentPathname}
transitionTime={pageTransitionTime}
on:navigate={(event) => {
event.detail.direction === 'right' ? (directionMultiplier = 1) : (directionMultiplier = -1)
currentPathname = event.detail.pathname
goto(currentPathname)
}}
/>
</footer>
</div>
{/if} -->
{/if}
<style>
#content-grid {
display: grid;
grid-template-columns: max-content auto;
grid-template-rows: 100%;
}
#bottom-tab-list {
padding: 16px 0px;
font-size: 20px;
line-height: 28px;
}
</style>

View File

@@ -1 +1,32 @@
<h1>Welcome to the User Page!</h1>
<script lang="ts">
import IconButton from '$lib/components/util/iconButton.svelte'
import type { LayoutData } from '../$types'
import { goto } from '$app/navigation'
export let data: LayoutData
</script>
<main class="flex flex-col gap-8">
<section class="flex items-center justify-between text-xl">
<div class="flex items-center gap-4">
<div class="grid aspect-square h-36 place-items-center rounded-full bg-neutral-800">
<i class="fa-solid fa-user text-6xl text-neutral-400" />
</div>
<div>
<div>{data.user.username}</div>
<div class="text-base text-neutral-400">Other info about the user</div>
</div>
</div>
<div class="flex h-10 gap-6">
<IconButton on:click={() => goto('/settings')} halo={true}>
<i slot="icon" class="fa-solid fa-gear" />
</IconButton>
<IconButton halo={true}>
<i slot="icon" class="fa-solid fa-right-from-bracket" />
</IconButton>
</div>
</section>
<section>
<div>This is where things like history would go</div>
</section>
</main>

View File

@@ -1,5 +1,5 @@
import type { LayoutServerLoad } from './$types'
export const load: LayoutServerLoad = ({ url, locals }) => {
return { urlPathname: url.pathname, user: locals.user }
export const load: LayoutServerLoad = ({ locals }) => {
return { user: locals.user }
}

View File

@@ -6,7 +6,7 @@
import { fade } from 'svelte/transition'
let alertBox: AlertBox
$: if ($newestAlert !== null && alertBox) alertBox.addAlert(...$newestAlert)
$: if ($newestAlert && alertBox) alertBox.addAlert(...$newestAlert)
</script>
<svelte:window bind:innerWidth={$pageWidth} />

View File

@@ -0,0 +1,22 @@
<script>
import IconButton from '$lib/components/util/iconButton.svelte'
</script>
<main class="h-full">
<h1 class="sticky top-0 grid grid-cols-[1fr_auto_1fr] grid-rows-1 items-center">
<IconButton on:click={() => history.back()}>
<i slot="icon" class="fa-solid fa-arrow-left text-2xl" />
</IconButton>
<span class="text-3xl">Account</span>
</h1>
<section class="px-[5vw]">
<slot />
</section>
</main>
<style>
h1 {
height: 80px;
padding: 16px 5vw;
}
</style>

View File

@@ -0,0 +1,5 @@
<script lang="ts">
import NavMenu from './navMenu.svelte'
</script>
<NavMenu />

View File

@@ -0,0 +1,20 @@
<script lang="ts">
import IconButton from '$lib/components/util/iconButton.svelte'
</script>
<nav class="flex w-full flex-col divide-y-2 divide-neutral-700 rounded-lg bg-neutral-800 px-4 text-xl">
<button class="flex items-center justify-between px-4 py-6">
<span>
<i class="fa-solid fa-circle-nodes mr-2" />
Connections
</span>
<i class="fa-solid fa-arrow-right" />
</button>
<button class="flex items-center justify-between px-4 py-6">
<span>
<i class="fa-solid fa-mobile-screen mr-2" />
Devices
</span>
<i class="fa-solid fa-arrow-right" />
</button>
</nav>