2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-10-29 18:06:21 +00:00
|
|
|
<div class="user-thumbnail-box" :style="{ height: size, width: size }">
|
|
|
|
<img
|
|
|
|
v-if="!imgError && Boolean(src)"
|
|
|
|
id="image"
|
|
|
|
:src="src"
|
2020-02-05 05:57:22 +00:00
|
|
|
:class="thumbnailClass"
|
2019-10-29 18:06:21 +00:00
|
|
|
@error="onImgError()"
|
|
|
|
/>
|
|
|
|
<Avatar
|
|
|
|
v-else
|
|
|
|
:username="username"
|
2020-02-05 05:57:22 +00:00
|
|
|
:class="thumbnailClass"
|
2019-10-29 18:06:21 +00:00
|
|
|
background-color="#1f93ff"
|
|
|
|
color="white"
|
2019-11-14 08:16:43 +00:00
|
|
|
:size="avatarSize"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2019-10-29 18:06:21 +00:00
|
|
|
<img
|
2020-02-09 10:17:48 +00:00
|
|
|
v-if="badge === 'Channel::FacebookPage'"
|
2019-10-29 18:06:21 +00:00
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
2019-11-14 08:16:43 +00:00
|
|
|
:style="badgeStyle"
|
2019-10-29 18:06:21 +00:00
|
|
|
src="~dashboard/assets/images/fb-badge.png"
|
|
|
|
/>
|
2020-02-02 17:04:16 +00:00
|
|
|
<div
|
2020-02-09 10:17:48 +00:00
|
|
|
v-else-if="badge === 'Channel::WebWidget' && status === 'online'"
|
2020-02-02 17:04:16 +00:00
|
|
|
class="source-badge user--online"
|
|
|
|
:style="statusStyle"
|
|
|
|
></div>
|
2020-02-02 19:09:00 +00:00
|
|
|
<img
|
2020-02-09 10:17:48 +00:00
|
|
|
v-if="badge === 'Channel::TwitterProfile'"
|
2020-02-02 19:09:00 +00:00
|
|
|
id="badge"
|
|
|
|
class="source-badge"
|
|
|
|
:style="badgeStyle"
|
|
|
|
src="~dashboard/assets/images/twitter-badge.png"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
/**
|
|
|
|
* Thumbnail Component
|
|
|
|
* Src - source for round image
|
|
|
|
* Size - Size of the thumbnail
|
|
|
|
* Badge - Chat source indication { fb / telegram }
|
2019-10-29 18:06:21 +00:00
|
|
|
* Username - User name for avatar
|
2019-08-14 09:48:44 +00:00
|
|
|
*/
|
2019-10-29 18:06:21 +00:00
|
|
|
import Avatar from './Avatar';
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2019-10-29 18:06:21 +00:00
|
|
|
components: {
|
|
|
|
Avatar,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
props: {
|
|
|
|
src: {
|
|
|
|
type: String,
|
2020-02-02 17:04:16 +00:00
|
|
|
default: '',
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: '40px',
|
|
|
|
},
|
|
|
|
badge: {
|
|
|
|
type: String,
|
|
|
|
default: 'fb',
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
username: {
|
|
|
|
type: String,
|
2020-02-02 17:04:16 +00:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2019-10-29 18:06:21 +00:00
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
hasBorder: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
imgError: false,
|
|
|
|
};
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
computed: {
|
|
|
|
avatarSize() {
|
|
|
|
return Number(this.size.replace(/\D+/g, ''));
|
|
|
|
},
|
|
|
|
badgeStyle() {
|
|
|
|
const badgeSize = `${this.avatarSize / 3}px`;
|
|
|
|
return { width: badgeSize, height: badgeSize };
|
|
|
|
},
|
2020-02-02 17:04:16 +00:00
|
|
|
statusStyle() {
|
|
|
|
const statusSize = `${this.avatarSize / 4}px`;
|
|
|
|
return { width: statusSize, height: statusSize };
|
|
|
|
},
|
2020-02-05 05:57:22 +00:00
|
|
|
thumbnailClass() {
|
|
|
|
const classname = this.hasBorder ? 'border' : '';
|
|
|
|
return `user-thumbnail ${classname}`;
|
|
|
|
},
|
2019-11-14 08:16:43 +00:00
|
|
|
},
|
2019-10-29 18:06:21 +00:00
|
|
|
methods: {
|
|
|
|
onImgError() {
|
|
|
|
this.imgError = true;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
2019-10-16 09:06:17 +00:00
|
|
|
</script>
|
2019-12-15 18:23:04 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
2020-02-02 17:04:16 +00:00
|
|
|
@import '~dashboard/assets/scss/foundation-settings';
|
2019-12-15 18:23:04 +00:00
|
|
|
@import '~dashboard/assets/scss/mixins';
|
|
|
|
|
|
|
|
.user-thumbnail-box {
|
|
|
|
@include flex-shrink;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.user-thumbnail {
|
|
|
|
border-radius: 50%;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
2020-02-05 05:57:22 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
&.border {
|
|
|
|
border: 1px solid white;
|
|
|
|
}
|
2019-12-15 18:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.source-badge {
|
2020-02-02 17:04:16 +00:00
|
|
|
bottom: -$space-micro;
|
2019-12-15 18:23:04 +00:00
|
|
|
height: $space-slab;
|
|
|
|
position: absolute;
|
|
|
|
right: $zero;
|
|
|
|
width: $space-slab;
|
|
|
|
}
|
2020-02-02 17:04:16 +00:00
|
|
|
|
|
|
|
.user--online {
|
|
|
|
background: $success-color;
|
|
|
|
border-radius: 50%;
|
|
|
|
bottom: $space-micro;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: ' ';
|
|
|
|
}
|
|
|
|
}
|
2019-12-15 18:23:04 +00:00
|
|
|
}
|
|
|
|
</style>
|