elk/components/account/AccountAvatar.vue
Andrew Crescencio 008248ee0f
fix(ui): Profile avatar image motion setting #3044 (#3066)
Co-authored-by: null <null>
2024-11-27 09:09:33 +00:00

34 lines
981 B
Vue

<script setup lang="ts">
import type { mastodon } from 'masto'
const { account, square } = defineProps<{
account: mastodon.v1.Account
square?: boolean
}>()
const loaded = ref(false)
const error = ref(false)
const preferredMotion = usePreferredReducedMotion()
const accountAvatarSrc = computed(() => {
return preferredMotion.value === 'reduce' ? account.avatarStatic : account.avatar
})
</script>
<template>
<img
:key="account.avatar"
width="400"
height="400"
select-none
:src="(error || !loaded) ? 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' : accountAvatarSrc"
:alt="$t('account.avatar_description', [account.username])"
loading="lazy"
class="account-avatar"
:class="(loaded ? 'bg-base' : 'bg-gray:10') + (square ? ' ' : ' rounded-full')"
:style="{ 'clip-path': square ? `url(#avatar-mask)` : 'none' }"
v-bind="$attrs"
@load="loaded = true"
@error="error = true"
>
</template>