mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 05:46:35 +00:00
Allow theming badge label color and hide empty label. (#1060)
This commit is contained in:
parent
0a5767913a
commit
efa956a0b5
@ -48,7 +48,7 @@
|
||||
max-width: 68%; /* Parent width minus two times 16% padding */
|
||||
display: inline-block;
|
||||
background-color: var(--ha-label-badge-color, var(--primary-color));
|
||||
color: white;
|
||||
color: var(--ha-label-badge-label-color, white);
|
||||
border-radius: 1em;
|
||||
padding: 8% 16%;
|
||||
font-weight: 500;
|
||||
@ -82,7 +82,7 @@
|
||||
<iron-icon icon='[[icon]]' hidden$='[[computeHideIcon(icon, value, image)]]'></iron-icon>
|
||||
<span hidden$='[[computeHideValue(value, image)]]'>[[value]]</span>
|
||||
</div>
|
||||
<div hidden$='[[!label]]' class$='[[computeLabelClasses(label)]]'>
|
||||
<div hidden$='[[computeHideLabel(label)]]' class$='[[computeLabelClasses(label)]]'>
|
||||
<span>[[label]]</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -116,6 +116,10 @@ class HaLabelBadge extends Polymer.Element {
|
||||
return label && label.length > 5 ? 'label big' : 'label';
|
||||
}
|
||||
|
||||
computeHideLabel(label) {
|
||||
return !label || !label.trim();
|
||||
}
|
||||
|
||||
computeHideIcon(icon, value, image) {
|
||||
return !icon || value || image;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user