@burh/nuxt-core 1.0.426 → 1.0.427
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
:fallbackText="user.name"
|
|
40
40
|
:fallbackBackground="avatarColor"
|
|
41
41
|
fallbackSize="200x200"
|
|
42
|
+
:style=" `--avatar-color: #${avatarColor}` "
|
|
42
43
|
/>
|
|
43
44
|
</el-tooltip>
|
|
44
45
|
</div>
|
|
@@ -204,7 +205,7 @@ export default {
|
|
|
204
205
|
border: 2px solid transparent;
|
|
205
206
|
transition: border-color 0.5s;
|
|
206
207
|
border: 2px solid #fff;
|
|
207
|
-
background:
|
|
208
|
+
background: var(--avatar-color);
|
|
208
209
|
&--active {
|
|
209
210
|
border-color: #5865F2;
|
|
210
211
|
z-index: 10;
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<img
|
|
3
|
-
:src="(this.src) ? this.src : getNameInitials()"
|
|
4
|
-
:alt="this.alt"
|
|
5
|
-
@error="img => getImageFallback(img)"
|
|
6
|
-
>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
export default {
|
|
11
|
-
name: 'image-with-fallback',
|
|
12
|
-
props: {
|
|
13
|
-
src: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
17
|
-
alt: {
|
|
18
|
-
type: String,
|
|
19
|
-
required: true
|
|
20
|
-
},
|
|
21
|
-
randomColor: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
default: false
|
|
24
|
-
},
|
|
25
|
-
fallbackBackground: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: '5865f2'
|
|
28
|
-
},
|
|
29
|
-
fallbackColor: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'ffffff'
|
|
32
|
-
},
|
|
33
|
-
fallbackSize: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: '512x512'
|
|
36
|
-
},
|
|
37
|
-
fallbackText: {
|
|
38
|
-
type: String,
|
|
39
|
-
required: true
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
methods: {
|
|
43
|
-
getAvatarUrl() {
|
|
44
|
-
let size = this.fallbackSize;
|
|
45
|
-
let background = this.fallbackBackground;
|
|
46
|
-
let color = this.fallbackColor;
|
|
47
|
-
let text = this.getNameInitials();
|
|
48
|
-
|
|
49
|
-
const colors = ['5865F2', '9D35FC', 'FF539D', 'FF7D7E', 'FFCF02', '00b388'];
|
|
50
|
-
|
|
51
|
-
this.randomColor && (background = colors[Math.floor(Math.random() * (colors.length - 1))]);
|
|
52
|
-
|
|
53
|
-
return `https://via.placeholder.com/${size}/${background}/${color}?text=${text}`;
|
|
54
|
-
},
|
|
55
|
-
getImageFallback(img) {
|
|
56
|
-
img.target.src = this.getAvatarUrl();
|
|
57
|
-
},
|
|
58
|
-
getNameInitials() {
|
|
59
|
-
let userAvatarName;
|
|
60
|
-
|
|
61
|
-
if (this.fallbackText) {
|
|
62
|
-
userAvatarName = this.fallbackText.slice(0, 1).toUpperCase();
|
|
63
|
-
} else {
|
|
64
|
-
userAvatarName = 'BURH';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return userAvatarName;
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
</script>
|
|
72
|
-
|
|
73
|
-
<style lang="scss" scoped>
|
|
74
|
-
|
|
75
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<img
|
|
3
|
+
:src="(this.src) ? this.src : getNameInitials()"
|
|
4
|
+
:alt="this.alt"
|
|
5
|
+
@error="img => getImageFallback(img)"
|
|
6
|
+
>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: 'image-with-fallback',
|
|
12
|
+
props: {
|
|
13
|
+
src: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
alt: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
randomColor: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
fallbackBackground: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: '5865f2'
|
|
28
|
+
},
|
|
29
|
+
fallbackColor: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'ffffff'
|
|
32
|
+
},
|
|
33
|
+
fallbackSize: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: '512x512'
|
|
36
|
+
},
|
|
37
|
+
fallbackText: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
getAvatarUrl() {
|
|
44
|
+
let size = this.fallbackSize;
|
|
45
|
+
let background = this.fallbackBackground;
|
|
46
|
+
let color = this.fallbackColor;
|
|
47
|
+
let text = this.getNameInitials();
|
|
48
|
+
|
|
49
|
+
const colors = ['5865F2', '9D35FC', 'FF539D', 'FF7D7E', 'FFCF02', '00b388'];
|
|
50
|
+
|
|
51
|
+
this.randomColor && (background = colors[Math.floor(Math.random() * (colors.length - 1))]);
|
|
52
|
+
|
|
53
|
+
return `https://via.placeholder.com/${size}/${background}/${color}?text=${text}`;
|
|
54
|
+
},
|
|
55
|
+
getImageFallback(img) {
|
|
56
|
+
img.target.src = this.getAvatarUrl();
|
|
57
|
+
},
|
|
58
|
+
getNameInitials() {
|
|
59
|
+
let userAvatarName;
|
|
60
|
+
|
|
61
|
+
if (this.fallbackText) {
|
|
62
|
+
userAvatarName = this.fallbackText.slice(0, 1).toUpperCase();
|
|
63
|
+
} else {
|
|
64
|
+
userAvatarName = 'BURH';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return userAvatarName;
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<style lang="scss" scoped>
|
|
74
|
+
|
|
75
|
+
</style>
|