3
3
class =" VbCard"
4
4
:class =" computedClass"
5
5
v-if =" !isHiddenAsUnfocused"
6
+ :style =" computedStyle"
6
7
>
7
- <div class =" VbCard__title" v-if =" title || refresh" >
8
- <div class =" VbCard__title__text" v-if =" title" >
9
- {{ title }}
10
- </div >
11
- <div class =" VbCard__title__spacer" />
12
- <div
13
- v-if =" refresh"
14
- class =" VbCard__title__icon"
15
- @click =" doRefresh()"
16
- title =" Refresh"
17
- >
18
- <FontAwesomeIcon
8
+ <template v-if =" title || refresh " >
9
+ <div class =" VbCard__title" >
10
+ <div class =" VbCard__title__text" v-if =" title" >
11
+ {{ title }}
12
+ </div >
13
+ <div class =" VbCard__title__spacer" />
14
+ <div
15
+ v-if =" focus"
16
+ class =" VbCard__title__icon"
17
+ title =" This card is focused. Not focused cards won't be displayed"
18
+ style =" font-weight : 700 ; color : white ; background-color : #d8365d ; border-radius : 16px ; width : 16px "
19
+ >
20
+ <span >F</span >
21
+ </div >
22
+ <div
23
+ v-if =" refresh"
24
+ class =" VbCard__title__icon"
25
+ style =" cursor : pointer "
26
+ @click =" doRefresh()"
19
27
title =" Refresh"
20
- icon =" sync"
21
- />
28
+ >
29
+ <FontAwesomeIcon
30
+ title =" Refresh"
31
+ icon =" sync"
32
+ />
33
+ </div >
22
34
</div >
23
- </div >
24
- <div
25
- class =" VbCard__content"
26
- ref =" content"
27
- :style =" computedStyle"
28
- >
29
- <slot v-if =" show" />
30
- </div >
35
+
36
+ <div class =" VbCard__separator" />
37
+ </template >
38
+
39
+ <slot v-if =" show" />
31
40
</div >
32
41
</template >
33
42
@@ -43,50 +52,49 @@ export default {
43
52
],
44
53
data : () => ({
45
54
show: true ,
46
- contentStyleTemp : null ,
55
+ cardStyleTemp : null ,
47
56
}),
48
57
props: {
49
58
noPadding: Boolean ,
50
59
dashed: Boolean ,
51
60
title: String ,
52
61
refresh: Boolean ,
62
+ dark: Boolean ,
53
63
width: String ,
54
64
height: String ,
55
65
color: String ,
56
66
},
57
67
computed: {
58
68
computedStyle () {
59
- const computedStyle = {
60
- ' min-width' : this .width ,
61
- ' min-height' : this .height ,
62
- height: undefined ,
63
- width: undefined ,
64
- backgroundColor: this .color ,
69
+ if (this .cardStyleTemp ) {
70
+ return {
71
+ ... this .cardStyleTemp ,
72
+ backgroundColor: this .color ,
73
+ }
65
74
}
66
- if (this .contentStyleTemp ) {
67
- computedStyle .height = this .contentStyleTemp .height
68
- computedStyle .width = this .contentStyleTemp .width
75
+
76
+ return {
77
+ height: this .height ,
78
+ width: this .width ,
79
+ backgroundColor: this .color ,
69
80
}
70
- return computedStyle
71
81
},
72
82
computedClass () {
73
83
return {
74
84
' VbCard--no-padding' : this .noPadding ,
75
85
' VbCard--dashed' : this .dashed ,
86
+ ' VbCard--dark' : this .dark ,
76
87
}
77
88
},
78
89
},
79
90
methods: {
80
91
doRefresh () {
81
- const computedStyle = window .getComputedStyle (this .$refs .content )
82
- this .contentStyleTemp = {
83
- width: computedStyle .width ,
84
- height: computedStyle .height ,
85
- }
92
+ const { width, height } = window .getComputedStyle (this .$el )
93
+ this .cardStyleTemp = { width , height }
86
94
this .show = false
87
95
88
96
setTimeout (() => {
89
- this .contentStyleTemp = null
97
+ this .cardStyleTemp = null
90
98
this .show = true
91
99
})
92
100
},
@@ -95,16 +103,46 @@ export default {
95
103
</script >
96
104
97
105
<style lang="scss">
106
+ @import " ../../scss/resources" ;
107
+
108
+ $card-content-padding : 20px ;
109
+
98
110
.VbCard {
99
111
margin : 5px ;
100
112
background-color : white ;
113
+ padding : $card-content-padding ;
114
+
115
+ & --dark {
116
+ background-color : #252525 ;
117
+
118
+ .VbCard__title {
119
+ color : #ededed ;
120
+ background-color : #252525 ;
121
+ }
122
+
123
+ .VbCard__separator {
124
+ background-color : #9d9d9d ;
125
+ }
126
+
127
+ & .VbCard--dashed {
128
+ border : dashed #d0daee 1px ;
129
+ }
130
+ }
101
131
102
132
& __title {
133
+ background-color : white ;
103
134
display : flex ;
104
- border-bottom : 1px solid rgba (0 , 0 , 0 , 0.2 );
135
+ margin : (- $card-content-padding ) (- $card-content-padding ) 0 ;
136
+ padding : 3px 5px ;
137
+ align-items : center ;
138
+
139
+ @at-root {
140
+ .VbCard.VbCard--no-padding & {
141
+ margin : 0 ;
142
+ }
143
+ }
105
144
106
145
& __text {
107
- padding : 3px 5px ;
108
146
font-weight : 700 ;
109
147
}
110
148
@@ -113,26 +151,34 @@ export default {
113
151
}
114
152
115
153
& __icon {
116
- font-size : 12px ;
117
- padding : 4px ;
154
+ margin-left : 4px ;
155
+ font-size : 14px ;
156
+ padding : 2px ;
118
157
user-select : none ;
158
+ @include flexCenter ();
119
159
120
160
& :hover {
121
- cursor : pointer ;
122
161
color : gray ;
123
162
}
124
163
}
125
164
}
126
165
127
- & __content {
128
- padding : 20px ;
166
+ & __separator {
167
+ height : 1px ;
168
+ background-color : rgba (0 , 0 , 0 , 0.2 );
169
+ margin : 0 (- $card-content-padding ) $card-content-padding ;
170
+
129
171
@at-root {
130
172
.VbCard.VbCard--no-padding & {
131
- padding : 0 ;
173
+ margin : 0 ;
132
174
}
133
175
}
134
176
}
135
177
178
+ & --no-padding {
179
+ padding : 0 ;
180
+ }
181
+
136
182
& --dashed {
137
183
border : dashed #7c8391 1px ;
138
184
}
0 commit comments