flotilla/src/app/components/SpaceMember.svelte

62 lines
2.3 KiB
Svelte
Raw Normal View History

2026-06-22 20:36:57 +00:00
<script lang="ts">
import {ManagementMethod} from "@welshman/util"
import {displayProfileByPubkey} from "@welshman/app"
2026-07-03 16:20:45 +00:00
import MenuButton from "@lib/components/MenuButton.svelte"
2026-06-22 20:36:57 +00:00
import Profile from "@app/components/Profile.svelte"
2026-07-03 00:01:31 +00:00
import ProfileAbout from "@app/components/ProfileAbout.svelte"
2026-06-22 20:36:57 +00:00
import ProfileDetail from "@app/components/ProfileDetail.svelte"
2026-07-03 16:20:45 +00:00
import SpaceMemberMenu from "@app/components/SpaceMemberMenu.svelte"
2026-06-22 20:36:57 +00:00
import RoleBadge from "@app/components/RoleBadge.svelte"
2026-07-03 16:20:45 +00:00
import {type SpaceRole} from "@app/members"
2026-06-22 20:36:57 +00:00
import {deriveSupportedMethods} from "@app/relays"
import {pushModal} from "@app/modal"
interface Props {
url: string
pubkey: string
roles?: SpaceRole[]
}
const {url, pubkey, roles = []}: Props = $props()
const supportedMethods = deriveSupportedMethods(url)
const canUnallow = $derived($supportedMethods.includes(ManagementMethod.UnallowPubkey))
const canBan = $derived($supportedMethods.includes(ManagementMethod.BanPubkey))
const canAssign = $derived($supportedMethods.some(m => (m as string) === "assignrole"))
const canUnassign = $derived($supportedMethods.some(m => (m as string) === "unassignrole"))
2026-07-03 16:20:45 +00:00
const openProfile = () => pushModal(ProfileDetail, {pubkey, url})
2026-06-22 20:36:57 +00:00
</script>
<div class="card card-interactive card-sm relative">
2026-06-22 20:36:57 +00:00
<button
type="button"
class="absolute inset-0 cursor-pointer rounded-2xl"
2026-06-22 20:36:57 +00:00
aria-label="View {displayProfileByPubkey(pubkey)}'s profile"
onclick={openProfile}>
</button>
<div class="pointer-events-none relative flex items-start justify-between gap-2">
<div class="flex min-w-0 flex-1 flex-col gap-1">
<Profile {pubkey} {url} inert />
{#if roles.length > 0}
<div class="flex flex-wrap gap-1">
{#each roles as role (role.id)}
<RoleBadge {role} />
{/each}
</div>
{/if}
<div class="line-clamp-1 text-sm opacity-70">
2026-07-03 00:01:31 +00:00
<ProfileAbout {pubkey} {url} singleLine />
2026-06-22 20:36:57 +00:00
</div>
</div>
{#if canAssign || canUnassign || canUnallow || canBan}
2026-07-03 16:20:45 +00:00
<div class="pointer-events-auto shrink-0">
<MenuButton
class="button button-ghost button-sm button-square"
2026-07-03 16:20:45 +00:00
component={SpaceMemberMenu}
componentProps={{url, pubkey}} />
</div>
{/if}
2026-06-22 20:36:57 +00:00
</div>
</div>