flotilla/src/app/components/RelayItem.svelte

44 lines
1.4 KiB
Svelte
Raw Normal View History

2024-10-03 18:49:52 +00:00
<script lang="ts">
import Icon from "@lib/components/Icon.svelte"
import Link from "@lib/components/Link.svelte"
2024-10-08 18:39:16 +00:00
import {displayUrl} from "@welshman/lib"
import {displayRelayUrl} from "@welshman/util"
import {deriveRelay} from "@welshman/app"
2024-10-03 18:49:52 +00:00
2025-02-04 00:37:14 +00:00
let {url, children} = $props()
2024-10-03 18:49:52 +00:00
const relay = deriveRelay(url)
2025-02-04 00:37:14 +00:00
let connections = $derived($relay?.stats?.open_count || 0)
2024-10-03 18:49:52 +00:00
</script>
<div class="card2 card2-sm bg-alt column gap-2">
2024-10-15 19:02:11 +00:00
<div class="flex items-center justify-between gap-4">
<div class="ellipsize flex items-center gap-2">
2024-10-18 22:58:44 +00:00
<Icon icon="server" />
2024-10-14 19:55:08 +00:00
<p class="ellipsize">{displayRelayUrl(url)}</p>
2024-10-03 18:49:52 +00:00
</div>
2025-02-04 00:37:14 +00:00
{@render children?.()}
2024-10-03 18:49:52 +00:00
</div>
{#if $relay?.profile?.description}
2024-10-14 19:55:08 +00:00
<p class="ellipsize">{$relay?.profile.description}</p>
2024-10-03 18:49:52 +00:00
{/if}
2024-10-15 19:02:11 +00:00
<span class="flex items-center gap-1 whitespace-nowrap text-sm">
2024-10-03 18:49:52 +00:00
{#if $relay?.profile?.contact}
2024-10-15 19:02:11 +00:00
<Link external class="ellipsize underline" href={$relay.profile.contact}
2024-10-03 18:49:52 +00:00
>{displayUrl($relay.profile.contact)}</Link>
&bull;
{/if}
{#if $relay?.profile?.supported_nips}
2024-10-08 18:39:16 +00:00
<span
class="tooltip cursor-pointer underline"
data-tip="NIPs supported: {$relay.profile.supported_nips.join(', ')}">
2024-10-03 18:49:52 +00:00
{$relay.profile.supported_nips.length} NIPs
</span>
&bull;
{/if}
2024-10-08 18:39:16 +00:00
Connected {connections}
{connections === 1 ? "time" : "times"}
2024-10-03 18:49:52 +00:00
</span>
</div>