2024-08-05 21:45:16 +00:00
|
|
|
<script lang="ts">
|
2025-05-13 17:14:20 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2024-12-16 19:49:57 +00:00
|
|
|
import {page} from "$app/stores"
|
2024-11-19 18:11:31 +00:00
|
|
|
import {goto} from "$app/navigation"
|
2025-05-07 15:57:49 +00:00
|
|
|
import {splitAt} from "@welshman/lib"
|
2025-10-17 17:19:21 +00:00
|
|
|
import {userProfile, shouldUnwrap} from "@welshman/app"
|
2025-11-11 21:39:32 +00:00
|
|
|
import Widget from "@assets/icons/widget.svg?dataurl"
|
|
|
|
|
import Compass from "@assets/icons/compass.svg?dataurl"
|
|
|
|
|
import Letter from "@assets/icons/letter.svg?dataurl"
|
|
|
|
|
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
|
|
|
|
import HomeSmile from "@assets/icons/home-smile.svg?dataurl"
|
|
|
|
|
import SettingsMinimalistic from "@assets/icons/settings-minimalistic.svg?dataurl"
|
|
|
|
|
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
|
|
|
|
import Settings from "@assets/icons/settings.svg?dataurl"
|
|
|
|
|
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
2024-10-21 22:19:55 +00:00
|
|
|
import Divider from "@lib/components/Divider.svelte"
|
2024-08-06 20:10:10 +00:00
|
|
|
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
|
2024-11-19 18:11:31 +00:00
|
|
|
import ChatEnable from "@app/components/ChatEnable.svelte"
|
2025-05-07 15:57:49 +00:00
|
|
|
import MenuOtherSpaces from "@app/components/MenuOtherSpaces.svelte"
|
2024-10-09 23:11:23 +00:00
|
|
|
import MenuSettings from "@app/components/MenuSettings.svelte"
|
2024-11-14 18:53:13 +00:00
|
|
|
import PrimaryNavItemSpace from "@app/components/PrimaryNavItemSpace.svelte"
|
2025-10-15 16:04:17 +00:00
|
|
|
import {userSpaceUrls, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/core/state"
|
2025-08-21 22:01:31 +00:00
|
|
|
import {pushModal} from "@app/util/modal"
|
|
|
|
|
import {makeSpacePath} from "@app/util/routes"
|
|
|
|
|
import {notifications} from "@app/util/notifications"
|
2025-05-13 17:14:20 +00:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
children?: Snippet
|
2025-02-04 00:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {children}: Props = $props()
|
2024-08-14 20:38:55 +00:00
|
|
|
|
2025-05-07 15:57:49 +00:00
|
|
|
const showOtherSpacesMenu = () => pushModal(MenuOtherSpaces, {urls: secondarySpaceUrls})
|
2024-10-09 23:11:23 +00:00
|
|
|
|
|
|
|
|
const showSettingsMenu = () => pushModal(MenuSettings)
|
2024-11-19 18:11:31 +00:00
|
|
|
|
2025-10-17 17:19:21 +00:00
|
|
|
const openChat = () => ($shouldUnwrap ? goto("/chat") : pushModal(ChatEnable, {next: "/chat"}))
|
2024-12-16 19:24:10 +00:00
|
|
|
|
2025-05-07 15:57:49 +00:00
|
|
|
const hasNotification = (url: string) => {
|
|
|
|
|
const path = makeSpacePath(url)
|
|
|
|
|
|
|
|
|
|
return !$page.url.pathname.startsWith(path) && $notifications.has(path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let windowHeight = $state(0)
|
|
|
|
|
|
|
|
|
|
const itemHeight = 56
|
|
|
|
|
const navPadding = 6 * itemHeight
|
|
|
|
|
const itemLimit = $derived((windowHeight - navPadding) / itemHeight)
|
2025-10-15 16:04:17 +00:00
|
|
|
const [primarySpaceUrls, secondarySpaceUrls] = $derived(splitAt(itemLimit, $userSpaceUrls))
|
|
|
|
|
const anySpaceNotifications = $derived($userSpaceUrls.some(hasNotification))
|
2025-05-07 15:57:49 +00:00
|
|
|
const otherSpaceNotifications = $derived(secondarySpaceUrls.some(hasNotification))
|
2024-08-05 21:45:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-07 15:57:49 +00:00
|
|
|
<svelte:window bind:innerHeight={windowHeight} />
|
|
|
|
|
|
2025-05-08 18:05:27 +00:00
|
|
|
<div
|
|
|
|
|
class="ml-sai mt-sai mb-sai relative z-nav hidden w-14 flex-shrink-0 bg-base-200 pt-4 md:block">
|
2025-09-05 23:21:17 +00:00
|
|
|
<div class="flex h-full flex-col" class:justify-between={PLATFORM_RELAYS.length === 0}>
|
2024-10-21 17:51:37 +00:00
|
|
|
<div>
|
2025-05-29 20:37:23 +00:00
|
|
|
{#each PLATFORM_RELAYS as url (url)}
|
|
|
|
|
<PrimaryNavItemSpace {url} />
|
2024-10-21 17:51:37 +00:00
|
|
|
{:else}
|
2024-10-22 18:16:32 +00:00
|
|
|
<PrimaryNavItem title="Home" href="/home" class="tooltip-right">
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Home" src={PLATFORM_LOGO} class="rounded-full" size={10} />
|
2024-10-22 18:16:32 +00:00
|
|
|
</PrimaryNavItem>
|
|
|
|
|
<Divider />
|
2025-05-07 15:57:49 +00:00
|
|
|
{#each primarySpaceUrls as url (url)}
|
2024-11-14 18:53:13 +00:00
|
|
|
<PrimaryNavItemSpace {url} />
|
2024-10-18 22:58:44 +00:00
|
|
|
{/each}
|
2025-05-07 15:57:49 +00:00
|
|
|
{#if secondarySpaceUrls.length > 0}
|
|
|
|
|
<PrimaryNavItem
|
|
|
|
|
title="Other Spaces"
|
|
|
|
|
class="tooltip-right"
|
|
|
|
|
onclick={showOtherSpacesMenu}
|
|
|
|
|
notification={otherSpaceNotifications}>
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Other Spaces" src={Widget} size={8} />
|
2025-05-07 15:57:49 +00:00
|
|
|
</PrimaryNavItem>
|
|
|
|
|
{/if}
|
2025-09-22 22:48:13 +00:00
|
|
|
<PrimaryNavItem title="Add a Space" href="/discover" class="tooltip-right">
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Add a Space" src={Compass} size={8} />
|
2024-10-18 22:58:44 +00:00
|
|
|
</PrimaryNavItem>
|
2025-05-29 20:37:23 +00:00
|
|
|
{/each}
|
2024-10-21 17:51:37 +00:00
|
|
|
</div>
|
2025-09-05 23:21:17 +00:00
|
|
|
{#if PLATFORM_RELAYS.length > 0}
|
|
|
|
|
<Divider />
|
|
|
|
|
{/if}
|
2024-10-21 17:51:37 +00:00
|
|
|
<div>
|
2024-10-21 21:09:57 +00:00
|
|
|
<PrimaryNavItem
|
|
|
|
|
title="Settings"
|
|
|
|
|
href="/settings/profile"
|
|
|
|
|
prefix="/settings"
|
|
|
|
|
class="tooltip-right">
|
2026-01-16 19:33:03 +00:00
|
|
|
{#if $userProfile?.picture}
|
|
|
|
|
<ImageIcon alt="Settings" src={$userProfile?.picture} class="rounded-full" size={10} />
|
|
|
|
|
{:else}
|
|
|
|
|
<ImageIcon alt="Settings" src={UserRounded} class="rounded-full" size={8} />
|
|
|
|
|
{/if}
|
2024-10-21 17:51:37 +00:00
|
|
|
</PrimaryNavItem>
|
2024-11-14 18:53:13 +00:00
|
|
|
<PrimaryNavItem
|
|
|
|
|
title="Messages"
|
2025-02-04 01:21:46 +00:00
|
|
|
onclick={openChat}
|
2024-11-14 18:53:13 +00:00
|
|
|
class="tooltip-right"
|
2024-12-16 19:24:10 +00:00
|
|
|
notification={$notifications.has("/chat")}>
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Messages" src={Letter} size={8} />
|
2024-10-21 17:51:37 +00:00
|
|
|
</PrimaryNavItem>
|
2024-10-21 20:46:32 +00:00
|
|
|
<PrimaryNavItem title="Search" href="/people" class="tooltip-right">
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Search" src={Magnifier} size={8} />
|
2024-10-21 20:46:32 +00:00
|
|
|
</PrimaryNavItem>
|
2024-08-05 21:45:16 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-10-21 17:51:37 +00:00
|
|
|
</div>
|
2024-10-09 21:19:27 +00:00
|
|
|
|
2025-02-04 00:37:14 +00:00
|
|
|
{@render children?.()}
|
2024-10-09 21:19:27 +00:00
|
|
|
|
2025-02-01 01:40:14 +00:00
|
|
|
<!-- a little extra something for ios -->
|
2025-12-03 01:20:10 +00:00
|
|
|
<div
|
|
|
|
|
class="bottom-nav hide-on-keyboard fixed bottom-0 left-0 right-0 z-nav h-[var(--saib)] bg-base-100 md:hidden">
|
2025-11-25 23:30:40 +00:00
|
|
|
</div>
|
2024-10-18 23:09:17 +00:00
|
|
|
<div
|
2025-12-03 01:20:10 +00:00
|
|
|
class="bottom-nav hide-on-keyboard border-top bottom-sai fixed left-0 right-0 z-nav h-14 border border-base-200 bg-base-100 md:hidden">
|
2024-10-22 17:16:31 +00:00
|
|
|
<div class="content-padding-x content-sizing flex justify-between px-2">
|
2025-10-28 23:46:49 +00:00
|
|
|
<div class="flex gap-2 sm:gap-6">
|
2025-01-15 18:56:56 +00:00
|
|
|
<PrimaryNavItem title="Home" href="/home">
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Home" src={HomeSmile} size={8} />
|
2025-01-15 18:56:56 +00:00
|
|
|
</PrimaryNavItem>
|
2024-12-16 19:24:10 +00:00
|
|
|
<PrimaryNavItem
|
|
|
|
|
title="Messages"
|
2025-02-04 01:21:46 +00:00
|
|
|
onclick={openChat}
|
2024-12-16 19:24:10 +00:00
|
|
|
notification={$notifications.has("/chat")}>
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Messages" src={Letter} size={8} />
|
2024-10-18 21:37:38 +00:00
|
|
|
</PrimaryNavItem>
|
2025-05-29 20:37:23 +00:00
|
|
|
{#if PLATFORM_RELAYS.length !== 1}
|
2025-10-28 23:46:49 +00:00
|
|
|
<PrimaryNavItem title="Spaces" href="/spaces" notification={anySpaceNotifications}>
|
2026-01-16 19:33:03 +00:00
|
|
|
<ImageIcon alt="Spaces" src={SettingsMinimalistic} size={8} />
|
2025-05-13 17:14:20 +00:00
|
|
|
</PrimaryNavItem>
|
|
|
|
|
{/if}
|
2024-10-18 21:37:38 +00:00
|
|
|
</div>
|
2025-02-04 01:21:46 +00:00
|
|
|
<PrimaryNavItem title="Settings" onclick={showSettingsMenu}>
|
2026-01-16 19:33:03 +00:00
|
|
|
{#if $userProfile?.picture}
|
|
|
|
|
<ImageIcon alt="Settings" src={$userProfile?.picture} size={10} class="rounded-full" />
|
|
|
|
|
{:else}
|
|
|
|
|
<ImageIcon alt="Settings" src={Settings} size={8} class="rounded-full" />
|
|
|
|
|
{/if}
|
2024-10-09 21:19:27 +00:00
|
|
|
</PrimaryNavItem>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|