mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-02-05 14:40:33 +08:00
69 lines
1.3 KiB
Vue
69 lines
1.3 KiB
Vue
<template>
|
|
<NuxtLink :to="url">
|
|
<img :title="username" :src="src" :alt="username" :class="'user-avatar ' + clazz" />
|
|
</NuxtLink>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { Component, Vue } from 'nuxt-property-decorator';
|
|
import { Prop } from 'vue-property-decorator';
|
|
import { PropType } from 'vue';
|
|
|
|
@Component
|
|
export default class UserAvatar extends Vue {
|
|
@Prop()
|
|
username!: String;
|
|
|
|
@Prop()
|
|
avatarUrl!: String;
|
|
|
|
@Prop()
|
|
imgSrc!: String;
|
|
|
|
@Prop()
|
|
clazz!: PropType<'user-avatar-md' | 'user-avatar-sm' | 'user-avatar-xs'>;
|
|
|
|
// attribute map // TODO implement
|
|
@Prop()
|
|
attr!: Object;
|
|
|
|
@Prop()
|
|
href!: String;
|
|
|
|
get src(): String {
|
|
if (this.imgSrc) {
|
|
return this.imgSrc;
|
|
} else if (this.avatarUrl) {
|
|
return this.avatarUrl;
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
get url(): String {
|
|
if (this.href) {
|
|
return this.href;
|
|
} else if (this.username) {
|
|
return '/' + this.username;
|
|
} else {
|
|
return '#';
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.user-avatar-md {
|
|
width: 100px;
|
|
height: 100px;
|
|
}
|
|
.user-avatar-sm {
|
|
width: 50px;
|
|
height: 50px;
|
|
}
|
|
.user-avatar-xs {
|
|
width: 32px;
|
|
height: 32px;
|
|
}
|
|
</style>
|