|
1 | 1 | <script lang="ts"> |
2 | | - import { page } from '$app/stores'; |
3 | | - import { onMount } from 'svelte'; |
4 | | -
|
5 | | - export let links: { name: string; href: string; match: RegExp }[]; |
6 | | -
|
7 | | - // Tweening for the indicator |
8 | | - let visible = false; |
9 | | - let navTween = { |
10 | | - left: '50%', |
11 | | - top: 0, |
12 | | - right: '50%', |
13 | | - }; |
14 | | -
|
15 | | - // Click handler |
16 | | - function updateLink(el: HTMLElement) { |
17 | | - visible = true; |
18 | | - navTween = { |
19 | | - left: el.offsetLeft, |
20 | | - right: el.parentElement.offsetWidth - el.offsetLeft - el.clientWidth, |
21 | | - top: el.offsetTop + el.offsetHeight, |
22 | | - }; |
23 | | - } |
24 | | -
|
25 | | - // Indicators |
26 | | - let indicators: HTMLElement[] = links.map(() => undefined); |
| 2 | + import Image from '$components/base/Image.svelte'; |
| 3 | + import { FEATURED_ARTIST } from '$lib/data/commissions'; |
| 4 | + import DesktopNavBar from './DesktopNavBar.svelte'; |
| 5 | + import MobileNavBar from './MobileNavBar.svelte'; |
27 | 6 |
|
28 | 7 | // Current page checker |
29 | | - const isCurrent = (link: (typeof links)[0]) => link.match.test($page.url.pathname); |
30 | | -
|
31 | | - // Recompute function |
32 | | - function recompute() { |
33 | | - // Find the current link |
34 | | - const currentLink = links.find(isCurrent); |
35 | | - if (!currentLink) { |
36 | | - visible = false; |
37 | | - return; |
38 | | - } |
39 | | -
|
40 | | - // Handle the link click |
41 | | - const index = links.indexOf(currentLink); |
42 | | - const indicator = indicators[index]; |
43 | | - if (!indicator) return; |
44 | | -
|
45 | | - updateLink(indicator); |
46 | | - } |
47 | | -
|
48 | | - // Load the initial indicator |
49 | | - onMount(recompute); |
50 | | - page.subscribe(recompute); |
51 | 8 | </script> |
52 | 9 |
|
53 | | -<!-- TODO: Mobile nav--> |
54 | | -<div class="relative flex w-fit flex-row items-center justify-end gap-4 pl-12 sm:justify-start md:gap-12 md:pl-24"> |
55 | | - {#each links as link, index} |
56 | | - <a class="group relative text-lg font-medium text-white opacity-75" href={link.href} bind:this={indicators[index]}> |
57 | | - {link.name} |
58 | | - <div |
59 | | - class="absolute -bottom-1 left-0 h-1 w-full rounded-full bg-transparent transition-all {!link.match.test($page.url.pathname) |
60 | | - ? 'group-hover:bg-primary-200/50' |
61 | | - : ''}" |
62 | | - /> |
63 | | - </a> |
64 | | - {/each} |
| 10 | +<div class="flex h-24 border-b border-b-white/10"> |
| 11 | + <div class="my-auto flex w-full flex-row items-center"> |
| 12 | + <!-- Avatar --> |
| 13 | + <Image class="aspect-square h-11 w-11 rounded-xl object-cover object-top" picture={FEATURED_ARTIST.commission.images[0]} alt="Logo" /> |
| 14 | + <div class="flex-grow md:hidden" /> |
65 | 15 |
|
66 | | - <!-- Nav link underline --> |
67 | | - <div |
68 | | - class="pointer-events-none absolute h-1 rounded-full bg-primary-200/50 transition-all duration-500 {visible ? '' : 'opacity-0'}" |
69 | | - style="left: {navTween.left}px; right: {navTween.right}px; top: {navTween.top}px;" |
70 | | - /> |
| 16 | + <!-- Navigation --> |
| 17 | + <DesktopNavBar /> |
| 18 | + <MobileNavBar /> |
| 19 | + </div> |
71 | 20 | </div> |
0 commit comments