2024-08-05 21:45:16 +00:00
|
|
|
<script lang="ts">
|
2025-05-13 17:14:20 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2026-07-27 22:38:23 +00:00
|
|
|
import cx from "classnames"
|
2026-07-30 01:24:57 +00:00
|
|
|
import {Profiles} from "@welshman/app"
|
2025-11-11 21:39:32 +00:00
|
|
|
import Letter from "@assets/icons/letter.svg?dataurl"
|
|
|
|
|
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
|
|
|
|
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
|
|
|
|
import Settings from "@assets/icons/settings.svg?dataurl"
|
2026-09-08 17:23:22 +00:00
|
|
|
import Sidebar from "@assets/icons/sidebar-minimalistic.svg?dataurl"
|
2025-11-11 21:39:32 +00:00
|
|
|
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
2024-10-21 22:19:55 +00:00
|
|
|
import Divider from "@lib/components/Divider.svelte"
|
2026-03-12 22:08:31 +00:00
|
|
|
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import MenuSettings from "@app/components/MenuSettings.svelte"
|
2026-03-12 22:08:31 +00:00
|
|
|
import PrimaryNavSpaces from "@app/components/PrimaryNavSpaces.svelte"
|
2026-09-07 20:53:25 +00:00
|
|
|
import Search from "@app/components/Search.svelte"
|
2026-09-08 17:23:22 +00:00
|
|
|
import SpaceMenuDrawer from "@app/components/SpaceMenuDrawer.svelte"
|
2026-09-09 02:34:18 +00:00
|
|
|
import {PLATFORM_RELAYS} from "@app/env"
|
2026-09-10 15:44:21 +00:00
|
|
|
import {modal, popModal, pushModal} from "@app/modal"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {notifications} from "@app/notifications"
|
2026-09-08 17:23:22 +00:00
|
|
|
import {userSpaceUrls} from "@app/rooms"
|
|
|
|
|
import {goToChat, lastSpaceUrl, makeSpacePath} from "@app/routes"
|
2026-07-30 01:24:57 +00:00
|
|
|
import {deriveUserItem} from "@app/core"
|
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
|
|
|
|
2026-07-30 01:24:57 +00:00
|
|
|
const userProfile = deriveUserItem(Profiles)
|
2026-07-28 16:16:26 +00:00
|
|
|
|
2026-03-23 21:21:04 +00:00
|
|
|
const chatHandler = () => goToChat()
|
|
|
|
|
|
2024-10-09 23:11:23 +00:00
|
|
|
const showSettingsMenu = () => pushModal(MenuSettings)
|
2024-11-19 18:11:31 +00:00
|
|
|
|
2026-09-07 20:53:25 +00:00
|
|
|
const showSearch = () => pushModal(Search)
|
|
|
|
|
|
2026-09-08 17:23:22 +00:00
|
|
|
// The menu is reachable from every page, so it opens on the space the user is in, or the last one
|
|
|
|
|
// they were in when they're somewhere else.
|
|
|
|
|
const spaceUrl = $derived($lastSpaceUrl ?? PLATFORM_RELAYS[0] ?? $userSpaceUrls[0])
|
|
|
|
|
|
|
|
|
|
const spaceMenuIsOpen = $derived($modal?.component === SpaceMenuDrawer)
|
|
|
|
|
|
|
|
|
|
const spaceMenuLabel = $derived(spaceMenuIsOpen ? "Close space menu" : "Open space menu")
|
|
|
|
|
|
|
|
|
|
const toggleSpaceMenu = () =>
|
2026-09-10 15:44:21 +00:00
|
|
|
spaceMenuIsOpen ? popModal() : pushModal(SpaceMenuDrawer, {url: spaceUrl}, {drawer: true})
|
2026-09-08 17:23:22 +00:00
|
|
|
|
|
|
|
|
const otherSpaceNotifications = $derived(
|
|
|
|
|
$userSpaceUrls.some(url => url !== spaceUrl && $notifications.has(makeSpacePath(url))),
|
2026-04-02 23:47:32 +00:00
|
|
|
)
|
2024-08-05 21:45:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-09-08 17:23:22 +00:00
|
|
|
<div
|
|
|
|
|
class={cx("primary-nav ml-sai mt-sai mb-sai hidden md:flex", {
|
|
|
|
|
"justify-between": PLATFORM_RELAYS.length === 0,
|
|
|
|
|
})}>
|
2026-06-24 20:56:53 +00:00
|
|
|
<PrimaryNavSpaces />
|
|
|
|
|
{#if PLATFORM_RELAYS.length > 0}
|
|
|
|
|
<Divider />
|
|
|
|
|
{/if}
|
2026-07-01 17:23:23 +00:00
|
|
|
<div class="flex flex-col items-center">
|
2026-06-24 20:56:53 +00:00
|
|
|
<PrimaryNavItem title="Settings" href="/settings/profile" prefix="/settings">
|
2026-07-28 16:16:26 +00:00
|
|
|
{#if $userProfile?.picture()}
|
2026-09-01 15:05:45 +00:00
|
|
|
<ImageIcon alt="Settings" src={$userProfile.picture()!} class="rounded-full" size={10} />
|
2026-06-24 20:56:53 +00:00
|
|
|
{:else}
|
|
|
|
|
<ImageIcon alt="Settings" src={UserRounded} class="rounded-full" size={8} />
|
|
|
|
|
{/if}
|
|
|
|
|
</PrimaryNavItem>
|
|
|
|
|
<PrimaryNavItem
|
|
|
|
|
title="Messages"
|
|
|
|
|
onclick={chatHandler}
|
|
|
|
|
notification={$notifications.has("/chat")}>
|
|
|
|
|
<ImageIcon alt="Messages" src={Letter} size={8} />
|
|
|
|
|
</PrimaryNavItem>
|
2026-09-07 20:53:25 +00:00
|
|
|
<PrimaryNavItem title="Search" onclick={showSearch}>
|
2026-06-24 20:56:53 +00:00
|
|
|
<ImageIcon alt="Search" src={Magnifier} size={8} />
|
|
|
|
|
</PrimaryNavItem>
|
2024-08-05 21:45:16 +00:00
|
|
|
</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 -->
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="hide-on-keyboard fixed bottom-0 left-0 right-0 z-nav h-(--saib) bg-surface md:hidden">
|
2025-11-25 23:30:40 +00:00
|
|
|
</div>
|
2024-10-18 23:09:17 +00:00
|
|
|
<div
|
2026-09-08 17:23:22 +00:00
|
|
|
class="hide-on-keyboard border-top bottom-sai fixed left-0 right-0 z-nav h-(--mobile-nav-height) border border-line bg-surface md:hidden">
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="flex h-full justify-between px-2">
|
|
|
|
|
<div class="flex items-center gap-6">
|
2026-09-08 17:23:22 +00:00
|
|
|
{#if spaceUrl}
|
|
|
|
|
<PrimaryNavItem
|
|
|
|
|
onclick={toggleSpaceMenu}
|
|
|
|
|
aria-label={spaceMenuLabel}
|
|
|
|
|
notification={otherSpaceNotifications}>
|
|
|
|
|
<ImageIcon alt={spaceMenuLabel} src={Sidebar} size={8} />
|
|
|
|
|
</PrimaryNavItem>
|
|
|
|
|
{/if}
|
2026-09-09 02:34:18 +00:00
|
|
|
<PrimaryNavItem onclick={showSearch}>
|
|
|
|
|
<ImageIcon alt="Search" src={Magnifier} size={8} />
|
|
|
|
|
</PrimaryNavItem>
|
2026-07-02 19:24:56 +00:00
|
|
|
<PrimaryNavItem href="/chat" onclick={chatHandler} 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>
|
|
|
|
|
</div>
|
2026-09-11 16:47:52 +00:00
|
|
|
<PrimaryNavItem onclick={showSettingsMenu} aria-label="Settings">
|
2026-07-28 16:16:26 +00:00
|
|
|
{#if $userProfile?.picture()}
|
|
|
|
|
<ImageIcon alt="Settings" src={$userProfile.picture()!} size={10} class="rounded-full" />
|
2026-01-16 19:33:03 +00:00
|
|
|
{:else}
|
|
|
|
|
<ImageIcon alt="Settings" src={Settings} size={8} class="rounded-full" />
|
|
|
|
|
{/if}
|
2024-10-09 21:19:27 +00:00
|
|
|
</PrimaryNavItem>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|