fix: adapt state color to tooltip properties (#1214)

This commit is contained in:
Robson Braga Araujo
2025-02-15 14:32:29 -08:00
committed by GitHub
parent 0d3c184dc1
commit 1142f259b1

View File

@@ -286,21 +286,24 @@ class MiniGraphCard extends LitElement {
}
renderState(entityConfig, id) {
const isPrimary = id === 0;
const isPrimary = id === 0; // rendering main state element?
if (isPrimary || entityConfig.show_state) {
const { entity, value: tooltipValue } = this.tooltip;
const state = this.getEntityState(id);
// use tooltip data for main state element, if tooltip is active
const { entity: tooltipEntity, value: tooltipValue } = this.tooltip;
const value = isPrimary && tooltipEntity !== undefined ? tooltipValue : state;
const entity = isPrimary && tooltipEntity !== undefined ? tooltipEntity : id;
return html`
<div
class="state ${!isPrimary && 'state--small'}"
@click=${e => this.handlePopup(e, this.entity[id])}
style=${entityConfig.state_adaptive_color ? `color: ${this.computeColor(state, id)};` : ''}>
${entityConfig.show_indicator ? this.renderIndicator(state, id) : ''}
style=${entityConfig.state_adaptive_color ? `color: ${this.computeColor(value, entity)}` : ''}>
${entityConfig.show_indicator ? this.renderIndicator(value, entity) : ''}
<span class="state__value ellipsis">
${this.computeState((isPrimary && tooltipValue !== undefined) ? tooltipValue : state)}
${this.computeState(value)}
</span>
<span class="state__uom ellipsis">
${this.computeUom(isPrimary && entity || id)}
${this.computeUom(entity)}
</span>
${isPrimary && this.renderStateTime() || ''}
</div>