blob: 54b5d50900abfa49152a2c6f102971cac25cc758 (
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
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
|
<template>
<div class="theme-preview">
<div class="badge-preview">
<img :src="icon" alt=""/>
<div class="badge" :style="style">8</div>
</div>
<iframe :src="url" class="popup-preview"/>
</div>
</template>
<script>
import Theme from '@js/Models/Theme/Theme';
import SystemService from '@js/Services/SystemService';
import ErrorManager from '@js/Manager/ErrorManager';
export default {
props: {
theme: Theme
},
data() {
return {
url : 'about:blank',
icon: null
};
},
mounted() {
this.url = 'preview.html';
SystemService.getFileUrl(`/img/${this.theme.getBadgeIcon()}.svg`)
.then((r) => {this.icon = r;})
.catch(ErrorManager.catch);
},
computed: {
style() {
return {
backgroundColor: this.theme.getBadgeBackgroundColor(),
color : this.theme.getBadgeForegroundColor()
};
}
},
watch: {
theme: {
deep: true,
handler(theme) {
SystemService.getFileUrl(`/img/${theme.getBadgeIcon()}.svg`)
.then((r) => {this.icon = r;})
.catch(ErrorManager.catch);
}
}
}
};
</script>
<style lang="scss">
.theme-preview {
.badge-preview {
border : 1px solid var(--element-hover-bg-color);
border-radius : 5px;
width : 40px;
height : 40px;
margin : .5rem auto;
padding : 7px;
position : relative;
img {
width : 24px;
height : 24px;
}
.badge {
position : absolute;
width : 1rem;
height : 1rem;
font-size : .8rem;
line-height : 1rem;
text-align : center;
border-radius : 3px;
right : -.4rem;
top : -.4rem;
&.bottom {
top : auto;
bottom : -.4rem;
}
}
}
.popup-preview {
height : 360px;
border : 1px solid var(--element-hover-bg-color);
width : 100%;
border-radius : 5px;
}
}
</style>
|