funkwhale/front/src/components/common/UserLink.vue

41 wiersze
912 B
Vue
Czysty Zwykły widok Historia

2018-07-17 11:09:13 +00:00
<template>
<span>
2020-01-06 09:16:05 +00:00
<template v-if="avatar">
<img
class="ui tiny circular avatar"
v-if="user.avatar && user.avatar.small_square_crop"
v-lazy="$store.getters['instance/absoluteUrl'](user.avatar.small_square_crop)" />
<span v-else :style="defaultAvatarStyle" class="ui circular label">{{ user.username[0]}}</span>
&nbsp;
</template>
@{{ user.username }}
2018-07-17 11:09:13 +00:00
</span>
</template>
<script>
import {hashCode, intToRGB} from '@/utils/color'
export default {
2020-01-06 09:16:05 +00:00
props: {
user: {required: true},
avatar: {type: Boolean, default: true}
},
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>
<style scoped>
.tiny.circular.avatar {
width: 1.7em;
height: 1.7em;
}
</style>