flotilla/src/app/components/PrimaryNav.svelte

86 lines
3.3 KiB
Svelte
Raw Normal View History

2024-08-05 21:45:16 +00:00
<script lang="ts">
import {displayRelayUrl} from "@welshman/util"
2024-10-01 23:27:25 +00:00
import {userProfile} from "@welshman/app"
2024-08-15 21:30:55 +00:00
import Avatar from "@lib/components/Avatar.svelte"
2024-08-06 20:10:10 +00:00
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
2024-08-16 17:50:38 +00:00
import SpaceAdd from "@app/components/SpaceAdd.svelte"
import SpaceAvatar from "@app/components/SpaceAvatar.svelte"
2024-10-09 23:11:23 +00:00
import MenuHome from "@app/components/MenuHome.svelte"
import MenuSpaces from "@app/components/MenuSpaces.svelte"
import MenuSettings from "@app/components/MenuSettings.svelte"
2024-10-08 22:30:18 +00:00
import {userMembership, getMembershipUrls} from "@app/state"
2024-08-08 21:02:46 +00:00
import {pushModal} from "@app/modal"
2024-10-09 23:15:09 +00:00
import {makeSpacePath} from "@app/routes"
2024-08-14 00:58:26 +00:00
const addSpace = () => pushModal(SpaceAdd)
2024-10-09 23:11:23 +00:00
const showHomeMenu = () => pushModal(MenuHome)
const showSpacesMenu = () => pushModal(MenuSpaces)
const showSettingsMenu = () => pushModal(MenuSettings)
2024-08-05 21:45:16 +00:00
</script>
2024-10-21 17:51:37 +00:00
<div class="relative hidden w-14 flex-shrink-0 bg-base-100 pt-4 md:block">
<div class="flex h-full flex-col justify-between">
<div>
<PrimaryNavItem href="/home/people" class="tooltip-right">
<Avatar icon="home-smile" class="!h-10 !w-10" />
</PrimaryNavItem>
{#if import.meta.env.VITE_PLATFORM_RELAY}
2024-10-09 23:15:09 +00:00
<PrimaryNavItem
2024-10-18 22:58:44 +00:00
title={displayRelayUrl(import.meta.env.VITE_PLATFORM_RELAY)}
href={makeSpacePath(import.meta.env.VITE_PLATFORM_RELAY)}
2024-10-09 23:15:09 +00:00
class="tooltip-right">
2024-10-18 22:58:44 +00:00
<SpaceAvatar url={import.meta.env.VITE_PLATFORM_RELAY} />
2024-08-14 00:58:26 +00:00
</PrimaryNavItem>
2024-10-21 17:51:37 +00:00
{:else}
2024-10-18 22:58:44 +00:00
{#each getMembershipUrls($userMembership) as url (url)}
<PrimaryNavItem
title={displayRelayUrl(url)}
href={makeSpacePath(url)}
class="tooltip-right">
<SpaceAvatar {url} />
</PrimaryNavItem>
{/each}
<PrimaryNavItem title="Add Space" on:click={addSpace} class="tooltip-right">
<Avatar icon="add-circle" class="!h-10 !w-10" />
</PrimaryNavItem>
<PrimaryNavItem title="Discover Spaces" href="/discover" class="tooltip-right">
<Avatar icon="compass-big" class="!h-10 !w-10" />
</PrimaryNavItem>
2024-10-21 17:51:37 +00:00
{/if}
</div>
<div>
<PrimaryNavItem title="Profile" href="/settings/profile" class="tooltip-right">
<Avatar src={$userProfile?.picture} class="!h-10 !w-10" />
</PrimaryNavItem>
<PrimaryNavItem title="Settings" href="/settings/relays" class="tooltip-right">
<Avatar icon="settings" class="!h-10 !w-10" />
</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
<slot />
2024-10-18 23:09:17 +00:00
<div
class="border-top fixed bottom-0 left-0 right-0 z-nav h-14 border border-base-200 bg-base-100 md:hidden">
<div class="m-auto flex max-w-md justify-between px-2">
<div class="flex gap-4 sm:gap-8">
<PrimaryNavItem title="Home" on:click={showHomeMenu}>
<Avatar icon="home-smile" class="!h-10 !w-10" />
</PrimaryNavItem>
<PrimaryNavItem title="Spaces" on:click={showSpacesMenu}>
<SpaceAvatar />
</PrimaryNavItem>
<PrimaryNavItem title="Settings" on:click={showSettingsMenu}>
<Avatar icon="settings" class="!h-10 !w-10" />
</PrimaryNavItem>
</div>
2024-10-18 22:58:44 +00:00
<PrimaryNavItem noActive title="Settings" href="/settings/profile">
<Avatar src={$userProfile?.picture} class="!h-10 !w-10" />
2024-10-09 21:19:27 +00:00
</PrimaryNavItem>
</div>
</div>