Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AvatarWrapper.vue « components « src - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 749c580d368b2cc5316cd23bd373d1d9443bcc9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<template>
	<div class="avatar-wrapper" :style="sessionAvatarStyle">
		<Avatar v-if="session.userId"
			:user="session.userId ? session.userId : session.guestName"
			:is-guest="session.userId === null"
			:disable-menu="true"
			:show-user-status="false"
			:disable-tooltip="true"
			:size="size" />
		<div v-else class="avatar" :style="sessionBackgroundStyle">
			{{ guestInitial }}
		</div>
	</div>
</template>

<script>
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
export default {
	name: 'AvatarWrapper',
	components: {
		Avatar,
	},
	props: {
		session: {
			type: Object,
			required: true,
		},
		size: {
			type: Number,
			default: () => 32,
		},
	},
	computed: {
		sessionAvatarStyle() {
			return {
				...this.sessionBackgroundStyle,
				'border-color': this.session.color,
				'border-width': '2px',
				'border-style': 'solid',
				'--size': this.size + 'px',
				'--font-size': this.size / 2 + 'px',
			}
		},
		sessionBackgroundStyle() {
			return {
				'background-color': this.session.userId ? this.session.color + ' !important' : '#b9b9b9',
			}
		},
		guestInitial() {
			return this.session.guestName === '' ? '?' : this.session.guestName.slice(0, 1).toUpperCase()
		},
	},
}
</script>

<style lang="scss" scoped>

.avatar, .avatar-wrapper {
	border-radius: 50%;
	width: var(--size);
	height: var(--size);
	text-align: center;
	color: #ffffff;
	line-height: var(--size);
	font-size: var(--font-size);
	font-weight: normal;
}
</style>