flotilla/src/lib/components/Avatar.svelte

20 lines
474 B
Svelte
Raw Normal View History

2024-08-15 21:30:55 +00:00
<script lang="ts">
2024-08-16 17:50:38 +00:00
import cx from "classnames"
2024-08-15 21:30:55 +00:00
import Icon from "@lib/components/Icon.svelte"
export let src
2024-08-23 20:33:36 +00:00
export let alt = ""
2024-08-15 21:30:55 +00:00
export let size = 7
2024-08-23 20:33:36 +00:00
export let icon = "user-rounded"
2024-08-15 21:30:55 +00:00
</script>
<div
2024-08-16 17:50:38 +00:00
class={cx($$props.class, "!flex items-center justify-center overflow-hidden rounded-full")}
2024-08-15 21:30:55 +00:00
style={`width: ${size * 4}px; height: ${size * 4}px;`}>
{#if src}
2024-08-23 20:33:36 +00:00
<img {alt} {src} />
2024-08-15 21:30:55 +00:00
{:else}
2024-08-23 20:33:36 +00:00
<Icon {icon} size={Math.round(size * 0.7)} />
2024-08-15 21:30:55 +00:00
{/if}
</div>