47 lines
923 B
Vue
47 lines
923 B
Vue
<template>
|
|
<q-avatar>
|
|
<slot :avatar-u-r-l="avatarURL(modelValue)">
|
|
<q-img :src="avatarURL(modelValue)" style="min-width: 100%; min-height: 100%">
|
|
<template #error>
|
|
<img :src="fallback" style="height: 100%" />
|
|
</template>
|
|
</q-img>
|
|
</slot>
|
|
</q-avatar>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { PropType, defineComponent } from 'vue';
|
|
import { avatarURL } from '@flaschengeist/api';
|
|
|
|
/**
|
|
* Display an avatar for an user
|
|
*
|
|
* Slots:
|
|
* default - scope: {avatarURL}
|
|
*/
|
|
export default defineComponent({
|
|
name: 'UserAvatar',
|
|
props: {
|
|
modelValue: {
|
|
type: [Object, String] as PropType<FG.User | string>,
|
|
required: true,
|
|
},
|
|
showZoom: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
fallback: {
|
|
type: String,
|
|
default: 'no-image.svg',
|
|
},
|
|
},
|
|
emits: ['error'],
|
|
setup() {
|
|
return {
|
|
avatarURL,
|
|
};
|
|
},
|
|
});
|
|
</script>
|