Files
radicle-explorer/shared/ui/components/RepoAvatar.svelte
T
Rūdolfs Ošiņš f79b23dde7 Share UI code through an npm workspace
Extracts the avatar components and the style tokens into shared/ui, which
both apps consume as a workspace package, to try out ADR 2. Nix and the
Docker setups are not updated yet.
2026-10-29 16:27:03 +01:00

38 lines
861 B
Svelte

<script lang="ts">
import { cachedRepoAvatar } from "../lib/avatar";
interface Props {
name: string;
rid: string;
styleWidth: string;
}
const { name, rid, styleWidth }: Props = $props();
let dataUri: string | undefined = $state(undefined);
$effect(() => {
// We strip out characters from the RID that repeat for all RIDs this leads
// to the generated avatars looking nicer visually.
const key = `${name}${rid.replace("rad:z", "")}${name}`;
void cachedRepoAvatar(key).then((data: string) => {
dataUri = data;
});
});
</script>
{#if dataUri}
<img
style:width={styleWidth}
style:height={styleWidth}
src={dataUri}
alt="Repository Avatar" />
{:else}
<div
style:width={styleWidth}
style:height={styleWidth}
style:background-color="var(--color-surface-subtle)">
</div>
{/if}