Files
Lazuli/src/routes/(app)/+layout.svelte
T

67 lines
3.1 KiB
Svelte
Raw Normal View History

2024-01-25 19:50:26 -05:00
<script lang="ts">
2024-01-26 01:30:18 -05:00
import { pageWidth } from '$lib/stores'
2024-01-28 02:41:13 -05:00
import type { LayoutData } from './$types'
import NavTab from '$lib/components/navbar/navTab.svelte'
import PlaylistTab from '$lib/components/navbar/playlistTab.svelte'
2024-01-28 02:41:13 -05:00
export let data: LayoutData
2024-01-25 19:50:26 -05:00
2024-01-28 02:41:13 -05:00
const inPathnameHeirarchy = (pathname: string, rootPathname: string): boolean => {
return (pathname.startsWith(rootPathname) && rootPathname !== '/') || (pathname === '/' && rootPathname === '/')
}
let playlistTooltip: HTMLDivElement
const setTooltip = (x: number, y: number, content: string): void => {
const textWrapper = playlistTooltip.firstChild! as HTMLDivElement
textWrapper.innerText = content
playlistTooltip.style.display = 'block'
playlistTooltip.style.left = `${x}px`
playlistTooltip.style.top = `${y}px`
}
2024-01-26 01:30:18 -05:00
</script>
2024-01-27 01:38:04 -05:00
{#if $pageWidth >= 768}
<div class="grid h-full grid-rows-1 gap-8 overflow-hidden">
<div class="no-scrollbar fixed left-0 top-0 z-10 grid h-full w-20 grid-cols-1 grid-rows-[min-content_auto] gap-5 px-3 py-16">
<div class="flex flex-col gap-4">
2024-01-29 12:29:32 -05:00
{#each data.navTabs as nav}
<NavTab {nav} disabled={inPathnameHeirarchy(data.url.pathname, nav.pathname)} />
2024-01-28 02:41:13 -05:00
{/each}
</div>
<div class="no-scrollbar flex flex-col gap-5 overflow-y-scroll px-1.5">
2024-01-29 12:29:32 -05:00
{#each data.playlistTabs as playlist}
<PlaylistTab {playlist} on:mouseenter={(event) => setTooltip(event.detail.x, event.detail.y, event.detail.content)} on:mouseleave={() => (playlistTooltip.style.display = 'none')} />
{/each}
</div>
<div bind:this={playlistTooltip} class="absolute hidden max-w-48 -translate-y-1/2 translate-x-10 whitespace-nowrap rounded bg-neutral-800 px-2 py-1.5 text-sm">
<div class="overflow-clip text-ellipsis">PLAYLIST_NAME</div>
<div class="overflow-clip text-ellipsis text-neutral-400">Playlist &bull; {data.user.username}</div>
</div>
2024-01-28 02:41:13 -05:00
</div>
2024-02-04 01:01:37 -05:00
<section class="no-scrollbar overflow-y-scroll px-[max(7rem,_7vw)] pt-16">
<slot />
2024-01-27 01:38:04 -05:00
</section>
<footer class="fixed bottom-0 flex w-full flex-col items-center justify-center">
<!-- <MiniPlayer displayMode={'horizontal'} /> -->
</footer>
</div>
{:else}
2024-01-26 01:30:18 -05:00
<div class="h-full overflow-hidden">
<section class="no-scrollbar h-full overflow-y-scroll px-[5vw] pt-16">
<slot />
</section>
2024-01-26 01:30:18 -05:00
<footer class="fixed bottom-0 flex w-full flex-col items-center justify-center">
2024-01-27 01:38:04 -05:00
<!-- <MiniPlayer displayMode={'vertical'} /> -->
2024-01-28 02:41:13 -05:00
<!-- <NavbarFoot
2024-01-27 01:38:04 -05:00
{currentPathname}
transitionTime={pageTransitionTime}
on:navigate={(event) => {
event.detail.direction === 'right' ? (directionMultiplier = 1) : (directionMultiplier = -1)
currentPathname = event.detail.pathname
goto(currentPathname)
}}
2024-01-28 02:41:13 -05:00
/> -->
2024-01-26 01:30:18 -05:00
</footer>
</div>
{/if}