mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-14 02:50:51 +08:00
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.
38 lines
861 B
Svelte
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}
|