flotilla/src/app/components/PrimaryNav.svelte

69 lines
2.3 KiB
Svelte
Raw Normal View History

2024-08-05 22:28:46 +00:00
<style>
.z-nav-active {
-webkit-mask-image: url("/nav-active.svg");
mask-image: url("/nav-active.svg");
}
</style>
2024-08-05 21:45:16 +00:00
<script lang="ts">
2024-08-09 00:22:17 +00:00
import {goto} from '$app/navigation'
2024-08-06 20:10:10 +00:00
import Icon from "@lib/components/Icon.svelte"
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
2024-08-08 21:02:46 +00:00
import SpaceAdd from '@app/components/SpaceAdd.svelte'
2024-08-09 23:22:09 +00:00
import {session} from "@app/base"
2024-08-13 19:41:25 +00:00
import {deriveGroupMembership, makeGroupId, getGroup, deriveProfile} from "@app/state"
2024-08-08 21:02:46 +00:00
import {pushModal} from "@app/modal"
export const addSpace = () => pushModal(SpaceAdd)
2024-08-09 00:22:17 +00:00
export const browseSpaces = () => goto("/browse")
2024-08-09 23:22:09 +00:00
2024-08-13 19:41:25 +00:00
$: profile = deriveProfile($session?.pubkey)
$: membership = deriveGroupMembership($session?.pubkey)
2024-08-05 21:45:16 +00:00
</script>
2024-08-05 22:28:46 +00:00
<div class="relative w-14 bg-base-100">
<div class="absolute -top-[44px] z-nav-active ml-2 h-[144px] w-12 bg-base-300" />
<div class="flex h-full flex-col justify-between">
2024-08-05 21:45:16 +00:00
<div>
2024-08-09 23:22:09 +00:00
<PrimaryNavItem title={$profile?.name}>
2024-08-13 19:41:25 +00:00
<div class="!flex w-10 items-center justify-center rounded-full border border-solid border-base-300">
{#if $profile?.picture}
<img alt="" src={$profile.picture} />
{:else}
<Icon icon="user-rounded" size={7} />
{/if}
2024-08-05 21:45:16 +00:00
</div>
</PrimaryNavItem>
2024-08-13 19:41:25 +00:00
{#each Array.from($membership?.ids || []) as groupId (groupId)}
{#await getGroup(groupId)}
<!-- pass -->
{:then group}
<PrimaryNavItem title={group?.name}>
<div class="w-10 rounded-full border border-solid border-base-300">
<img alt={group?.name} src={group?.picture} />
</div>
</PrimaryNavItem>
{/await}
2024-08-05 21:45:16 +00:00
{/each}
2024-08-08 21:02:46 +00:00
<PrimaryNavItem title="Add Space" on:click={addSpace}>
2024-08-05 22:28:46 +00:00
<div class="!flex w-10 items-center justify-center">
2024-08-05 21:45:16 +00:00
<Icon size={7} icon="add-circle" />
</div>
</PrimaryNavItem>
2024-08-09 00:22:17 +00:00
<PrimaryNavItem title="Browse Spaces" on:click={browseSpaces}>
2024-08-05 22:28:46 +00:00
<div class="!flex w-10 items-center justify-center">
2024-08-05 21:45:16 +00:00
<Icon size={6} icon="compass-big" />
</div>
</PrimaryNavItem>
</div>
<div>
<PrimaryNavItem title="Settings">
2024-08-05 22:28:46 +00:00
<div class="!flex w-10 items-center justify-center">
2024-08-05 21:45:16 +00:00
<Icon size={7} icon="settings" />
</div>
</PrimaryNavItem>
</div>
</div>
</div>