2018-07-17 11:09:13 +00:00
|
|
|
<template>
|
2020-05-15 12:12:36 +00:00
|
|
|
<span class="component-user-link">
|
2020-01-06 09:16:05 +00:00
|
|
|
<template v-if="avatar">
|
|
|
|
<img
|
2021-12-06 10:35:20 +00:00
|
|
|
v-if="user.avatar && user.avatar.urls.medium_square_crop"
|
|
|
|
v-lazy="$store.getters['instance/absoluteUrl'](user.avatar.urls.medium_square_crop)"
|
2020-01-06 09:16:05 +00:00
|
|
|
class="ui tiny circular avatar"
|
2020-08-01 17:07:06 +00:00
|
|
|
alt=""
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
|
|
|
<span
|
|
|
|
v-else
|
|
|
|
:style="defaultAvatarStyle"
|
|
|
|
class="ui circular label"
|
|
|
|
>{{ user.username[0] }}</span>
|
2020-01-06 09:16:05 +00:00
|
|
|
|
|
|
|
</template>
|
|
|
|
@{{ user.username }}
|
2018-07-17 11:09:13 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-12-06 10:35:20 +00:00
|
|
|
import { hashCode, intToRGB } from '@/utils/color'
|
2018-07-17 11:09:13 +00:00
|
|
|
|
|
|
|
export default {
|
2020-01-06 09:16:05 +00:00
|
|
|
props: {
|
2021-12-06 10:35:20 +00:00
|
|
|
user: { type: String, required: true },
|
|
|
|
avatar: { type: Boolean, default: true }
|
2020-01-06 09:16:05 +00:00
|
|
|
},
|
2018-07-17 11:09:13 +00:00
|
|
|
computed: {
|
|
|
|
userColor () {
|
|
|
|
return intToRGB(hashCode(this.user.username + String(this.user.id)))
|
|
|
|
},
|
|
|
|
defaultAvatarStyle () {
|
|
|
|
return {
|
|
|
|
'background-color': `#${this.userColor}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|