2025-11-11 21:39:32 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {relays} from "@app/core"
|
2026-09-07 23:09:02 +00:00
|
|
|
import {relayIconColor, relayIconInitials} from "@app/relays"
|
2025-11-11 21:39:32 +00:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
size?: number
|
|
|
|
|
class?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {url, size = 7, ...props}: Props = $props()
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const relay = $relays.one(url)
|
2026-09-07 23:09:02 +00:00
|
|
|
|
|
|
|
|
const rem = $derived(size * 0.25)
|
|
|
|
|
|
|
|
|
|
const fallbackStyle = $derived(
|
|
|
|
|
`width: ${rem}rem; height: ${rem}rem; min-width: ${rem}rem; min-height: ${rem}rem; font-size: ${rem * 0.4}rem; background-color: ${relayIconColor(url)}; color: white`,
|
|
|
|
|
)
|
2025-11-11 21:39:32 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-01-16 22:17:38 +00:00
|
|
|
{#if $relay?.icon}
|
2026-08-28 00:08:36 +00:00
|
|
|
<ImageIcon {size} alt="" src={$relay?.icon} class="rounded-full {props.class}" />
|
2026-01-16 22:17:38 +00:00
|
|
|
{:else}
|
2026-09-07 23:09:02 +00:00
|
|
|
<div
|
|
|
|
|
class="flex select-none items-center justify-center rounded-full font-bold {props.class}"
|
|
|
|
|
style={fallbackStyle}>
|
|
|
|
|
{relayIconInitials(url)}
|
|
|
|
|
</div>
|
2026-01-16 22:17:38 +00:00
|
|
|
{/if}
|