mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
29 lines
766 B
Vue
29 lines
766 B
Vue
<template>
|
|
<ds-avatar :image="avatarUrl" :name="userName" class="avatar" :size="size" />
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'HcAvatar',
|
|
props: {
|
|
user: { type: Object, default: null },
|
|
size: { type: String, default: 'small' },
|
|
},
|
|
computed: {
|
|
avatarUrl() {
|
|
const { avatar: imageSrc } = this.user || {}
|
|
if (!imageSrc) return imageSrc
|
|
return imageSrc.startsWith('/') ? imageSrc.replace('/', '/api/') : imageSrc
|
|
},
|
|
userName() {
|
|
const { name } = this.user || {}
|
|
// The name is used to display the initials in case
|
|
// the image cannot be loaded.
|
|
return name
|
|
// If the name is undefined, then our styleguide will
|
|
// display an icon for the anonymous user.
|
|
},
|
|
},
|
|
}
|
|
</script>
|