-
Notifications
You must be signed in to change notification settings - Fork 0
/
DpImage.vue
106 lines (104 loc) · 3.19 KB
/
DpImage.vue
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
<div id="ProfileDpImageWrapper" :style="cssProps">
{{initials}}
<img v-if="!initials.length" :src="imgsrc" :alt="alt" :title="profilePixTitle">
</div>
</template>
<script>
export default {
name: "DpImage",
props: {
imgsrc: {
type: String,
default: "",
required: false
},
alt: {
type: String,
default: "Admin DP",
required: false
},
title: {
type: String,
default: null,
required: false
},
firstname: {
type: String,
required: true
},
lastname: {
type: String,
default: "",
required: false
},
width: {
type: String,
default: "40px",
required: false
},
height: {
type: String,
default: null,
required: false
},
background: {
type: String,
default: "#222838",
required: false
},
color: {
type: String,
default: "#FFF",
required: false
},
radius: {
type: String,
default: "50%",
required: false
},
textsize: {
type: String,
default: "1.5rem",
required: false
}
},
computed: {
cssProps: function () {
return {
"--profile-dp-image-wrapper-width": this.width,
"--profile-dp-image-wrapper-height": (this.height || this.width),
"--profile-dp-image-wrapper-background": this.background,
"--profile-dp-image-wrapper-color": this.color,
"--profile-dp-image-wrapper-radius": this.radius,
"--profile-dp-image-wrapper-font-size": this.textsize,
}
},
initials: function () {
return (this.imgsrc.length > 4) ? '' : `${this.firstname.charAt(0)}${this.lastname.charAt(0)}`;
},
profilePixTitle: function () {
return this.title || `${this.firstname} ${this.lastname} Display Picture`;
}
}
}
</script>
<style scoped>
#ProfileDpImageWrapper {
width: var(--profile-dp-image-wrapper-width);
height: var(--profile-dp-image-wrapper-height);
line-height: var(--profile-dp-image-wrapper-height);
background: var(--profile-dp-image-wrapper-background);
color: var(--profile-dp-image-wrapper-color);
border-radius: var(--profile-dp-image-wrapper-radius);
font-size: var(--profile-dp-image-wrapper-font-size);
text-align: center;
display: inline-block;
font-weight: bolder;
}
#ProfileDpImageWrapper > img {
width: 100%;
max-width: 100%;
height: auto;
}
</style>