flotilla/src/app/components/PrimaryNav.svelte

97 lines
3.7 KiB
Svelte
Raw Normal View History

2024-08-05 21:45:16 +00:00
<script lang="ts">
import type {Snippet} from "svelte"
import {userProfile} from "@welshman/app"
import Letter from "@assets/icons/letter.svg?dataurl"
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
import Widget from "@assets/icons/widget-4.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-10-09 23:11:23 +00:00
import MenuSettings from "@app/components/MenuSettings.svelte"
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
import PrimaryNavSpaces from "@app/components/PrimaryNavSpaces.svelte"
import {userSpaceUrls} from "@app/groups"
import {PLATFORM_RELAYS} from "@app/env"
2026-06-08 21:14:40 +00:00
import {pushModal} from "@app/modal"
import {notifications} from "@app/notifications"
import {goToChat, makeSpacePath} from "@app/routes"
type Props = {
children?: Snippet
2025-02-04 00:37:14 +00:00
}
const {children}: Props = $props()
2026-03-23 21:21:04 +00:00
const chatHandler = () => goToChat()
2024-10-09 23:11:23 +00:00
const showSettingsMenu = () => pushModal(MenuSettings)
2026-04-02 23:47:32 +00:00
const anySpaceNotifications = $derived(
$userSpaceUrls.some(p => $notifications.has(makeSpacePath(p))),
)
2024-08-05 21:45:16 +00:00
</script>
2025-05-08 18:05:27 +00:00
<div
2026-06-22 20:36:57 +00:00
class="ml-sai mt-sai mb-sai relative z-popover isolate hidden w-14 shrink-0 bg-base-200 pt-2 md:block border-r border-solid border-base-content/15 dark:border-base-content/10">
2025-09-05 23:21:17 +00:00
<div class="flex h-full flex-col" class:justify-between={PLATFORM_RELAYS.length === 0}>
<PrimaryNavSpaces />
2025-09-05 23:21:17 +00:00
{#if PLATFORM_RELAYS.length > 0}
<Divider />
{/if}
<div class="flex flex-col">
<PrimaryNavItem title="Settings" href="/settings/profile" prefix="/settings">
{#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"
2026-03-23 21:21:04 +00:00
onclick={chatHandler}
2024-12-16 19:24:10 +00:00
notification={$notifications.has("/chat")}>
<ImageIcon alt="Messages" src={Letter} size={8} />
2024-10-21 17:51:37 +00:00
</PrimaryNavItem>
<PrimaryNavItem title="Search" href="/people">
<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 -->
2026-04-08 16:45:30 +00:00
<div class="hide-on-keyboard fixed bottom-0 left-0 right-0 z-nav h-(--saib) bg-base-100 md:hidden">
2025-11-25 23:30:40 +00:00
</div>
2024-10-18 23:09:17 +00:00
<div
2026-04-04 16:02:52 +00:00
class="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">
<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">
2026-03-17 22:03:40 +00:00
<PrimaryNavItem title="Search" href="/people">
<ImageIcon alt="Search" src={Magnifier} size={8} />
2025-01-15 18:56:56 +00:00
</PrimaryNavItem>
2024-12-16 19:24:10 +00:00
<PrimaryNavItem
title="Messages"
2026-03-17 22:03:40 +00:00
href="/chat"
2026-03-23 21:21:04 +00:00
onclick={chatHandler}
2024-12-16 19:24:10 +00:00
notification={$notifications.has("/chat")}>
<ImageIcon alt="Messages" src={Letter} size={8} />
</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}>
<ImageIcon alt="Spaces" src={Widget} size={8} />
</PrimaryNavItem>
{/if}
</div>
<PrimaryNavItem title="Settings" onclick={showSettingsMenu}>
{#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>