pleroma-fe/src/components/user_avatar/user_avatar.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

import StillImage from '../still-image/still-image.vue'
2025-01-30 21:56:07 +02:00
import { useInterfaceStore } from 'src/stores/interface'
import { library } from '@fortawesome/fontawesome-svg-core'
2026-01-06 16:22:52 +02:00
import { faRobot, faPeopleGroup } from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:22:52 +02:00
library.add(faRobot, faPeopleGroup)
const UserAvatar = {
2025-08-05 17:17:01 +03:00
props: {
// User object to show avatar of
user: {
required: true,
2026-01-06 16:22:52 +02:00
type: Object,
2025-08-05 17:17:01 +03:00
},
// Use less space and use alternative roundness
compact: {
required: false,
type: Boolean,
2026-01-06 16:22:52 +02:00
default: false,
2025-08-05 17:17:01 +03:00
},
// Show small icon indicating if account is a bot or group
2026-01-06 16:22:52 +02:00
showActorTypeIndicator: {
2025-08-05 17:17:01 +03:00
required: false,
type: Boolean,
2026-01-06 16:22:52 +02:00
default: false,
2025-08-05 17:17:01 +03:00
},
// Override avatar image URL, useful for profile editing
url: {
required: false,
type: String,
2026-01-06 16:22:52 +02:00
default: null,
},
2025-08-05 17:17:01 +03:00
},
2026-01-06 16:22:52 +02:00
data() {
return {
showPlaceholder: false,
defaultAvatar: `${this.$store.state.instance.server + this.$store.state.instance.defaultAvatar}`,
2026-01-06 16:22:52 +02:00
betterShadow: useInterfaceStore().browserSupport.cssFilter,
}
},
components: {
2026-01-06 16:22:52 +02:00
StillImage,
},
methods: {
2026-01-06 16:22:52 +02:00
imgSrc(src) {
return !src || this.showPlaceholder ? this.defaultAvatar : src
},
2026-01-06 16:22:52 +02:00
imageLoadError() {
this.showPlaceholder = true
2026-01-06 16:22:52 +02:00
},
},
}
export default UserAvatar