2024-08-14 21:52:00 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {onMount} from 'svelte'
|
|
|
|
|
import Masonry from 'svelte-bricks'
|
2024-08-15 19:08:07 +00:00
|
|
|
import {append, remove} from '@welshman/lib'
|
|
|
|
|
import {GROUP_META, displayRelayUrl} from '@welshman/util'
|
2024-08-14 21:52:00 +00:00
|
|
|
import Icon from '@lib/components/Icon.svelte'
|
2024-08-15 19:08:07 +00:00
|
|
|
import {makeSpacePath} from '@app/routes'
|
|
|
|
|
import {load, relays, groups, searchGroups, relayUrlsByNom, userMembership} from '@app/state'
|
|
|
|
|
import {updateGroupMemberships} from '@app/commands'
|
|
|
|
|
|
|
|
|
|
const getRelayUrls = (nom: string): string[] => $relayUrlsByNom.get(nom) || []
|
|
|
|
|
|
2024-08-14 21:52:00 +00:00
|
|
|
let term = ""
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
load({
|
|
|
|
|
relays: $relays.map(r => r.url),
|
|
|
|
|
filters: [{kinds: [GROUP_META]}],
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-08-14 23:25:36 +00:00
|
|
|
<div class="content column gap-4">
|
|
|
|
|
<h1 class="superheading mt-20">Discover Spaces</h1>
|
|
|
|
|
<p class="text-center">Find communities all across the nostr network</p>
|
|
|
|
|
<label class="input input-bordered w-full flex items-center gap-2">
|
|
|
|
|
<Icon icon="magnifer" />
|
|
|
|
|
<input bind:value={term} class="grow" type="text" placeholder="Search for spaces..." />
|
|
|
|
|
</label>
|
2024-08-15 19:08:07 +00:00
|
|
|
<Masonry animate={false} items={$searchGroups.searchOptions(term)} minColWidth={250} maxColWidth={800} gap={16} idKey="nom" let:item={group}>
|
2024-08-15 19:25:22 +00:00
|
|
|
<a href={makeSpacePath(group.nom)} class="card bg-base-100 shadow-xl hover:shadow-2xl hover:brightness-[1.1] transition-all">
|
2024-08-14 23:25:36 +00:00
|
|
|
<div class="avatar center mt-8">
|
2024-08-15 19:25:22 +00:00
|
|
|
<div class="w-20 rounded-full bg-base-300 border-2 border-solid border-base-300 !flex center relative">
|
2024-08-15 19:08:07 +00:00
|
|
|
{#if group?.picture}
|
|
|
|
|
<img alt="" src={group.picture} />
|
2024-08-14 21:52:00 +00:00
|
|
|
{:else}
|
|
|
|
|
<Icon icon="ghost" size={7} />
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-08-15 19:25:22 +00:00
|
|
|
{#if $userMembership?.noms.has(group.nom)}
|
|
|
|
|
<div class="absolute flex center w-full">
|
|
|
|
|
<div class="bg-primary rounded-full relative top-[38px] left-8 tooltip" data-tip="You are already a member of this space.">
|
|
|
|
|
<Icon icon="check-circle" class="scale-110" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-08-14 21:52:00 +00:00
|
|
|
<div class="card-body">
|
2024-08-15 19:25:22 +00:00
|
|
|
<h2 class="card-title justify-center">{group.name}</h2>
|
2024-08-15 19:08:07 +00:00
|
|
|
<div class="text-sm text-center">
|
|
|
|
|
{#each getRelayUrls(group.nom) as url}
|
|
|
|
|
<div class="badge badge-neutral">{displayRelayUrl(url)}</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
<p class="text-sm py-4">{group.about}</p>
|
2024-08-14 21:52:00 +00:00
|
|
|
</div>
|
2024-08-15 19:25:22 +00:00
|
|
|
</a>
|
2024-08-14 21:52:00 +00:00
|
|
|
</Masonry>
|
|
|
|
|
</div>
|