Foxnouns.NET/Foxnouns.Frontend/src/lib/components/Avatar.svelte

24 lines
467 B
Svelte
Raw Normal View History

<script lang="ts">
import { DEFAULT_AVATAR } from "$lib";
2024-11-25 17:35:24 +01:00
type Props = { url: string | null; alt: string; lazyLoad?: boolean; size?: number };
let { url, alt, lazyLoad, size }: Props = $props();
let width = $derived(size || 200);
</script>
<img
class="rounded-circle img-fluid"
2024-11-25 17:35:24 +01:00
style="height: {width}px; width: {width}px"
src={url || DEFAULT_AVATAR}
{alt}
2024-11-25 17:35:24 +01:00
{width}
loading={lazyLoad ? "lazy" : "eager"}
/>
2024-11-24 22:19:53 +01:00
<style>
img {
object-fit: cover;
}
</style>