flotilla/src/routes/spaces/[relay]/+page.svelte

103 lines
3.5 KiB
Svelte
Raw Normal View History

2024-09-23 20:10:15 +00:00
<script lang="ts">
import {page} from "$app/stores"
2025-06-05 15:35:17 +00:00
import {displayRelayUrl} from "@welshman/util"
import {deriveRelay} from "@welshman/app"
2024-09-23 20:10:15 +00:00
import Icon from "@lib/components/Icon.svelte"
2024-10-31 19:24:40 +00:00
import Link from "@lib/components/Link.svelte"
2024-12-11 19:25:39 +00:00
import Button from "@lib/components/Button.svelte"
2024-10-09 23:11:23 +00:00
import PageBar from "@lib/components/PageBar.svelte"
2025-03-19 17:30:36 +00:00
import PageContent from "@lib/components/PageContent.svelte"
2024-11-15 22:03:54 +00:00
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
import ProfileLatest from "@app/components/ProfileLatest.svelte"
2024-12-11 19:25:39 +00:00
import SpaceJoin from "@app/components/SpaceJoin.svelte"
2024-10-31 19:24:40 +00:00
import RelayName from "@app/components/RelayName.svelte"
import RelayDescription from "@app/components/RelayDescription.svelte"
2025-06-05 15:35:17 +00:00
import SpaceQuickLinks from "@app/components/SpaceQuickLinks.svelte"
import SpaceRecentActivity from "@app/components/SpaceRecentActivity.svelte"
2025-06-05 15:54:09 +00:00
import SpaceRelayStatus from "@app/components/SpaceRelayStatus.svelte"
import {decodeRelay, userRoomsByUrl} from "@app/state"
2025-06-05 15:35:17 +00:00
import {makeChatPath} from "@app/routes"
2024-12-11 19:25:39 +00:00
import {pushModal} from "@app/modal"
2024-09-23 20:10:15 +00:00
2024-10-21 17:30:12 +00:00
const url = decodeRelay($page.params.relay)
2024-10-31 19:24:40 +00:00
const relay = deriveRelay(url)
2024-12-11 19:25:39 +00:00
const joinSpace = () => pushModal(SpaceJoin, {url})
2025-06-05 03:42:28 +00:00
const owner = $derived($relay?.profile?.pubkey)
2024-09-23 20:10:15 +00:00
</script>
2025-03-19 17:30:36 +00:00
<PageBar>
{#snippet icon()}
<div class="center">
<Icon icon="home-smile" />
</div>
{/snippet}
{#snippet title()}
<strong>Home</strong>
{/snippet}
{#snippet action()}
<div class="row-2">
{#if !$userRoomsByUrl.has(url)}
<Button class="btn btn-primary btn-sm" onclick={joinSpace}>
<Icon icon="login-2" />
Join Space
</Button>
2025-06-05 03:42:28 +00:00
{:else if owner}
<Link class="btn btn-primary btn-sm" href={makeChatPath([owner])}>
2025-03-19 17:30:36 +00:00
<Icon icon="letter" />
Contact Owner
</Link>
{/if}
<MenuSpaceButton {url} />
</div>
{/snippet}
</PageBar>
2025-06-04 20:52:00 +00:00
<PageContent class="flex flex-col gap-2 p-2 pt-4">
<div class="card2 bg-alt flex flex-col gap-4 text-left">
2025-03-19 17:30:36 +00:00
<div class="relative flex gap-4">
<div class="relative">
<div class="avatar relative">
<div
2025-06-04 20:52:00 +00:00
class="center !flex h-16 w-16 min-w-16 rounded-full border-2 border-solid border-base-300 bg-base-300">
2025-03-19 17:30:36 +00:00
{#if $relay?.profile?.icon}
<img alt="" src={$relay.profile.icon} />
{:else}
2025-06-04 20:52:00 +00:00
<Icon icon="ghost" size={6} />
2025-03-19 17:30:36 +00:00
{/if}
</div>
</div>
</div>
2025-06-05 15:35:17 +00:00
<div class="flex min-w-0 flex-col gap-1">
2025-06-04 20:52:00 +00:00
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">
2025-03-19 17:30:36 +00:00
<RelayName {url} />
2025-06-04 20:52:00 +00:00
</h1>
2025-06-05 03:42:28 +00:00
<p class="ellipsize text-sm opacity-75">{displayRelayUrl(url)}</p>
2025-02-04 00:37:14 +00:00
</div>
2025-06-04 20:52:00 +00:00
</div>
2025-06-05 03:42:28 +00:00
<RelayDescription {url} />
2025-03-19 17:30:36 +00:00
</div>
2025-06-05 15:35:17 +00:00
<SpaceQuickLinks {url} />
2025-06-04 20:52:00 +00:00
<div class="grid grid-cols-1 gap-2 lg:grid-cols-2">
<div class="flex flex-col gap-2">
<SpaceRecentActivity {url} />
2025-03-19 17:30:36 +00:00
</div>
<div class="flex flex-col gap-2">
2025-06-05 15:54:09 +00:00
<SpaceRelayStatus {url} />
2025-06-05 03:42:28 +00:00
{#if owner}
<div class="card2 bg-alt">
<h3 class="mb-4 flex items-center gap-2 text-lg font-semibold">
<Icon icon="user-rounded" />
Latest Updates
</h3>
2025-06-05 03:42:28 +00:00
<ProfileLatest {url} pubkey={owner}>
{#snippet fallback()}
<p class="text-sm opacity-60">No recent posts from the relay admin</p>
{/snippet}
</ProfileLatest>
</div>
{/if}
2025-06-04 20:52:00 +00:00
</div>
</div>
2025-03-19 17:30:36 +00:00
</PageContent>