~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
40 lines · 951 B Raw History
<script lang="ts">
	import Icon, { type IconName } from './Icon.svelte';

	// A picture beside a name, of one size so names beside them line up: an
	// account's (round) or a client's logo (square), or an icon in its place
	// when there is none.
	let {
		src,
		shape = 'round',
		fallback = 'person'
	}: { src?: string; shape?: 'round' | 'square'; fallback?: IconName } = $props();
</script>

{#if src}
	<img class="avatar" class:square={shape === 'square'} {src} alt="" referrerpolicy="no-referrer" />
{:else}
	<span class="avatar none" class:square={shape === 'square'}><Icon name={fallback} /></span>
{/if}

<style>
	.avatar {
		flex: none;
		width: var(--avatar);
		height: var(--avatar);
		border-radius: var(--radius-full);
		object-fit: cover;
	}

	.square {
		border-radius: var(--radius-md);
	}

	.none {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		background: var(--soft);
		color: var(--mute);
	}
</style>