kopia lustrzana https://github.com/elk-zone/elk
refactor: code from profile avatar image reduced motion setting issue (#3069)
Co-authored-by: null <null>pull/2784/merge
rodzic
e1b8d5cb33
commit
b4cb027a8e
|
@ -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"
|
||||
|
|
Ładowanie…
Reference in New Issue