refactor: code from profile avatar image reduced motion setting issue (#3069)

Co-authored-by: null <null>
pull/2784/merge
Andrew Crescencio 2024-11-30 22:59:42 -03:00 zatwierdzone przez GitHub
rodzic e1b8d5cb33
commit b4cb027a8e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
const { account, square } = defineProps<{
const props = defineProps<{
account: mastodon.v1.Account
square?: boolean
}>()
@ -11,22 +11,22 @@ const error = ref(false)
const preferredMotion = usePreferredReducedMotion()
const accountAvatarSrc = computed(() => {
return preferredMotion.value === 'reduce' ? account.avatarStatic : account.avatar
return preferredMotion.value === 'reduce' ? (props.account?.avatarStatic ?? props.account.avatar) : props.account.avatar
})
</script>
<template>
<img
:key="account.avatar"
:key="props.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])"
:alt="$t('account.avatar_description', [props.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' }"
:class="(loaded ? 'bg-base' : 'bg-gray:10') + (props.square ? ' ' : ' rounded-full')"
:style="{ 'clip-path': props.square ? `url(#avatar-mask)` : 'none' }"
v-bind="$attrs"
@load="loaded = true"
@error="error = true"