mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Revert "Add icon support to gauge" (#8303)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
parent
d79e5dd8fb
commit
9d89aa329c
@ -14,7 +14,6 @@ import { styleMap } from "lit-html/directives/style-map";
|
|||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { stateIcon } from "../../../common/entity/state_icon";
|
|
||||||
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-gauge";
|
import "../../../components/ha-gauge";
|
||||||
@ -140,11 +139,8 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
"--gauge-color": this._computeSeverity(state),
|
"--gauge-color": this._computeSeverity(state),
|
||||||
})}
|
})}
|
||||||
></ha-gauge>
|
></ha-gauge>
|
||||||
<div class="row">
|
<div class="name">
|
||||||
<ha-icon .icon=${this._config.icon || stateIcon(stateObj)}></ha-icon>
|
${this._config.name || computeStateName(stateObj)}
|
||||||
<div class="name">
|
|
||||||
${this._config.name || computeStateName(stateObj)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
@ -236,25 +232,13 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
max-width: 250px;
|
max-width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-around;
|
|
||||||
margin-top: 4px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: initial;
|
line-height: initial;
|
||||||
color: var(--secondary-text-color);
|
color: var(--primary-text-color);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: 16px;
|
font-size: 15px;
|
||||||
font-weight: 500;
|
margin-top: 8px;
|
||||||
}
|
|
||||||
|
|
||||||
ha-icon {
|
|
||||||
color: var(--state-icon-color, #44739e);
|
|
||||||
margin-right: 4px;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@ export interface GaugeCardConfig extends LovelaceCardConfig {
|
|||||||
max?: number;
|
max?: number;
|
||||||
severity?: SeverityConfig;
|
severity?: SeverityConfig;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
icon?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigEntity extends EntityConfig {
|
export interface ConfigEntity extends EntityConfig {
|
||||||
|
@ -12,10 +12,8 @@ import {
|
|||||||
import { assert, number, object, optional, string } from "superstruct";
|
import { assert, number, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { computeRTLDirection } from "../../../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../../../common/util/compute_rtl";
|
||||||
import { stateIcon } from "../../../../common/entity/state_icon";
|
|
||||||
import "../../../../components/ha-formfield";
|
import "../../../../components/ha-formfield";
|
||||||
import "../../../../components/ha-switch";
|
import "../../../../components/ha-switch";
|
||||||
import "../../../../components/ha-icon-input";
|
|
||||||
import { HomeAssistant } from "../../../../types";
|
import { HomeAssistant } from "../../../../types";
|
||||||
import { GaugeCardConfig, SeverityConfig } from "../../cards/types";
|
import { GaugeCardConfig, SeverityConfig } from "../../cards/types";
|
||||||
import "../../components/hui-entity-editor";
|
import "../../components/hui-entity-editor";
|
||||||
@ -33,7 +31,6 @@ const cardConfigStruct = object({
|
|||||||
max: optional(number()),
|
max: optional(number()),
|
||||||
severity: optional(object()),
|
severity: optional(object()),
|
||||||
theme: optional(string()),
|
theme: optional(string()),
|
||||||
icon: optional(string()),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const includeDomains = ["sensor"];
|
const includeDomains = ["sensor"];
|
||||||
@ -78,10 +75,6 @@ export class HuiGaugeCardEditor extends LitElement
|
|||||||
return this._config!.severity || undefined;
|
return this._config!.severity || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get _icon(): string {
|
|
||||||
return this._config!.icon || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.hass || !this._config) {
|
if (!this.hass || !this._config) {
|
||||||
return html``;
|
return html``;
|
||||||
@ -112,30 +105,16 @@ export class HuiGaugeCardEditor extends LitElement
|
|||||||
.configValue=${"name"}
|
.configValue=${"name"}
|
||||||
@value-changed="${this._valueChanged}"
|
@value-changed="${this._valueChanged}"
|
||||||
></paper-input>
|
></paper-input>
|
||||||
<div class="side-by-side">
|
<paper-input
|
||||||
<paper-input
|
.label="${this.hass.localize(
|
||||||
.label="${this.hass.localize(
|
"ui.panel.lovelace.editor.card.generic.unit"
|
||||||
"ui.panel.lovelace.editor.card.generic.unit"
|
)} (${this.hass.localize(
|
||||||
)} (${this.hass.localize(
|
"ui.panel.lovelace.editor.card.config.optional"
|
||||||
"ui.panel.lovelace.editor.card.config.optional"
|
)})"
|
||||||
)})"
|
.value=${this._unit}
|
||||||
.value="${this._unit}"
|
configValue="unit"
|
||||||
.configValue=${"unit"}
|
@value-changed=${this._valueChanged}
|
||||||
@value-changed="${this._valueChanged}"
|
></paper-input>
|
||||||
></paper-input>
|
|
||||||
<ha-icon-input
|
|
||||||
.label="${this.hass.localize(
|
|
||||||
"ui.panel.lovelace.editor.card.generic.icon"
|
|
||||||
)} (${this.hass.localize(
|
|
||||||
"ui.panel.lovelace.editor.card.config.optional"
|
|
||||||
)})"
|
|
||||||
.value=${this._icon}
|
|
||||||
.placeholder=${this._icon ||
|
|
||||||
stateIcon(this.hass.states[this._entity])}
|
|
||||||
.configValue=${"icon"}
|
|
||||||
@value-changed=${this._valueChanged}
|
|
||||||
></ha-icon-input>
|
|
||||||
</div>
|
|
||||||
<hui-theme-select-editor
|
<hui-theme-select-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value="${this._theme}"
|
.value="${this._theme}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user