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