-
Notifications
You must be signed in to change notification settings - Fork 4
/
base.yaml
executable file
·305 lines (277 loc) · 7.63 KB
/
base.yaml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
base:
variables:
is_active: |
[[[ return ['on', 'open', 'Kotona', 'home', 'cleaning', 'returning', 'idle'].indexOf(entity === undefined || entity.state) !== -1; ]]]
template:
- language_variables
# Fix to https://github.com/custom-cards/button-card/issues/693
state_display: |
[[[
const domain = entity.entity_id.split(".")[0];
switch (entity.state) {
case "home":
return variables.text_state_home;
case "not_home":
return variables.text_state_not_home
default:
return variables[`text_state_${domain}_${entity.state}`];
}
]]]
styles:
card:
# Fixes ripple border-radius with Safari
- '-webkit-backface-visibility': hidden
- '-moz-backface-visibility': hidden
- '-webkit-transform': translate3d(0, 0, 0)
- '-moz-transform': translate3d(0, 0, 0)
base_card:
variables:
state_colors: false
card_glow: false
card_shadow_enabled: true
aspect_ratio: 1/1
template:
- base
styles:
name:
- font-size: 1rem
- font-weight: 500
label:
- font-size: 0.8rem
state:
- font-size: 0.9rem
- font-weight: 500
custom_fields:
state2:
- font-size: 0.9rem
state3:
- font-size: 0.9rem
card:
- border-radius: var(--border-radius)
- padding: var(--button-card-padding)
- '-webkit-box-shadow': |
[[[
if (!variables.card_glow) {
return variables.card_shadow_enabled ? 'var(--box-shadow)' : 'none'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return '0 0 0.95rem 0.2rem ' + color
}
}
if (variables.icon_color) {
return '0 0 0.95rem 0.2rem ' + variables.icon_color
}
return variables.card_shadow_enabled ? 'var(--box-shadow)' : 'none'
]]]
- box-shadow: |
[[[
if (!variables.card_glow) {
return variables.card_shadow_enabled ? 'var(--box-shadow)' : 'none'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return '0 0 0.95rem 0.2rem ' + color
}
}
if (variables.icon_color) {
return '0 0 0.95rem 0.2rem ' + variables.icon_color
}
return variables.card_shadow_enabled ? 'var(--box-shadow)' : 'none'
]]]
- transition: |
[[[
if (!variables.card_glow) {
return 'none'
} else {
return 'all 2s ease'
}
]]]
# Cannot inherit base_card
compact_card:
aspect_ratio: null
styles:
card:
- height: var(--button-card-compact-height)
wide_card:
aspect_ratio: 2/1
base_icon_button:
template:
- base
show_name: false
show_state: false
show_icon: true
styles:
icon:
- width: 1.8rem
- color: |
[[[
return variables.is_active ? 'var(--primary-text-color)' : 'var(--custom-icon-color-not-active)'
]]]
img_cell:
- width: 3rem
- height: 2.5rem
- background-color: transparent
- border-radius: 50%
- justify-self: center
- align-self: center
card:
- box-shadow: none
- background-color: 'rgba(var(--primary-text-color-rgb), 0.05)'
- border-radius: 1rem
base_icon:
template:
- base
variables:
icon_glow: false
state_colors: false
icon_color: false
show_icon: true
styles:
icon:
- width: 1.6rem
- color: |
[[[
if (!entity) {
if (variables.icon_color) {
return variables.icon_color
}
return 'var(--custom-icon-color-not-active)'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return color
}
}
if (variables.icon_color) {
return variables.icon_color
}
return 'var(--custom-icon-color-not-active)'
]]]
- filter: |
[[[
if (!entity) {
return 'none'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return `drop-shadow(0 0 var(--button-card-icon-drop-shadow-size) ${color})`
}
}
if (variables.icon_color) {
return `drop-shadow(0 0 var(--button-card-icon-drop-shadow-size) ${variables.icon_color})`
}
return 'none'
]]]
- transition: all 2s ease
img_cell:
- background-color: var(--custom-color-icon-background)
- border-radius: 50%
- justify-self: start
- '-webkit-box-shadow': |
[[[
if (!variables.icon_glow) {
return 'none'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return '0 0 var(--button-card-img-cell-box-shadow-size) ' + color
}
}
if (variables.icon_color) {
return '0 0 var(--button-card-img-cell-box-shadow-size) ' + variables.icon_color
}
return 'none'
]]]
- box-shadow: |
[[[
if (!variables.icon_glow) {
return 'none'
}
var state = entity.state
if (variables.state_colors) {
var color = variables.state_colors[state]
if (color) {
return '0 0 var(--button-card-img-cell-box-shadow-size)' + color
}
}
if (variables.icon_color) {
return '0 0 var(--button-card-img-cell-box-shadow-size) ' + variables.icon_color
}
return 'none'
]]]
- transition: all 2s ease
base_icon_name:
show_icon: true
show_name: true
show_label: false
show_state: false
template:
- base_icon
styles:
img_cell:
- background-color: var(--custom-color-icon-background)
- border-radius: 50%
- width: 3rem
- height: 3rem
- place-self: center
name:
- justify-self: start
- align-self: center
# Templates with grid styles
icon_name_state:
template:
- base_icon_name
show_state: true
styles:
grid:
- grid-template-areas: |
"i n"
"i s"
- grid-template-columns: 2.5rem 3.5fr
- grid-template-rows: 1.25rem 1.25rem
name:
- padding-left: 0.8rem
- align-self: end
- font-size: 1rem
- font-weight: 500
state:
- font-size: 0.9rem
- font-weight: 500
- filter: opacity(40%)
- place-self: start start
- padding-left: 0.8rem
card:
- box-shadow: none
- border-radius: var(--border-radius)
- padding: 0 0 0 0
- margin: 0 0 0 0
- overflow: visible
empty:
variables:
height: 6rem
show_name: false
show_label: false
show_icon: false
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
styles:
card:
- height: "[[[ return variables.height ]]]"
- background-color: transparent
- box-shadow: none
- '--mdc-ripple-press-opacity': 0