mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
light-card: icon option (#3771)
* light-card: icon option closes https://github.com/home-assistant/home-assistant-polymer/issues/3768 * add theme select label property * address review comments
This commit is contained in:
parent
eee0c2e53f
commit
9a7eb3d406
@ -107,7 +107,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
|
||||
<ha-icon
|
||||
class="light-icon"
|
||||
data-state="${stateObj.state}"
|
||||
.icon="${stateIcon(stateObj)}"
|
||||
.icon="${this._config.icon || stateIcon(stateObj)}"
|
||||
style="${styleMap({
|
||||
filter: this._computeBrightness(stateObj),
|
||||
color: this._computeColor(stateObj),
|
||||
|
@ -107,6 +107,7 @@ export interface LightCardConfig extends LovelaceCardConfig {
|
||||
entity: string;
|
||||
name?: string;
|
||||
theme?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export interface MapCardConfig extends LovelaceCardConfig {
|
||||
|
@ -26,7 +26,7 @@ declare global {
|
||||
@customElement("hui-theme-select-editor")
|
||||
export class HuiThemeSelectEditor extends LitElement {
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public label?: string;
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
@ -36,7 +36,8 @@ export class HuiThemeSelectEditor extends LitElement {
|
||||
|
||||
return html`
|
||||
<paper-dropdown-menu
|
||||
label="Theme"
|
||||
.label=${this.label ||
|
||||
this.hass!.localize("ui.panel.lovelace.editor.theme_select.theme")}
|
||||
dynamic-align
|
||||
@value-changed="${this._changed}"
|
||||
>
|
||||
|
@ -23,6 +23,7 @@ const cardConfigStruct = struct({
|
||||
name: "string?",
|
||||
entity: "string?",
|
||||
theme: "string?",
|
||||
icon: "string?",
|
||||
});
|
||||
|
||||
@customElement("hui-light-card-editor")
|
||||
@ -49,6 +50,10 @@ export class HuiLightCardEditor extends LitElement
|
||||
return this._config!.entity || "";
|
||||
}
|
||||
|
||||
get _icon(): string {
|
||||
return this._config!.icon || "";
|
||||
}
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
if (!this.hass) {
|
||||
return html``;
|
||||
@ -57,28 +62,37 @@ export class HuiLightCardEditor extends LitElement
|
||||
return html`
|
||||
${configElementStyle}
|
||||
<div class="card-config">
|
||||
<paper-input
|
||||
label="Name"
|
||||
.value="${this._name}"
|
||||
.configValue="${"name"}"
|
||||
@value-changed="${this._valueChanged}"
|
||||
></paper-input>
|
||||
<ha-entity-picker
|
||||
label="Light Entity (Required)"
|
||||
.hass="${this.hass}"
|
||||
.value="${this._entity}"
|
||||
.configValue=${"entity"}
|
||||
domain-filter="light"
|
||||
@change="${this._valueChanged}"
|
||||
allow-custom-entity
|
||||
></ha-entity-picker>
|
||||
<div class="side-by-side">
|
||||
<ha-entity-picker
|
||||
.hass="${this.hass}"
|
||||
.value="${this._entity}"
|
||||
.configValue=${"entity"}
|
||||
domain-filter="light"
|
||||
@change="${this._valueChanged}"
|
||||
allow-custom-entity
|
||||
></ha-entity-picker>
|
||||
<hui-theme-select-editor
|
||||
.hass="${this.hass}"
|
||||
.value="${this._theme}"
|
||||
.configValue="${"theme"}"
|
||||
@theme-changed="${this._valueChanged}"
|
||||
></hui-theme-select-editor>
|
||||
<paper-input
|
||||
label="Name (Optional)"
|
||||
.value="${this._name}"
|
||||
.configValue="${"name"}"
|
||||
@value-changed="${this._valueChanged}"
|
||||
></paper-input>
|
||||
<paper-input
|
||||
label="Icon (Optional)"
|
||||
.value="${this._icon}"
|
||||
.configValue="${"icon"}"
|
||||
@value-changed="${this._valueChanged}"
|
||||
></paper-input>
|
||||
</div>
|
||||
|
||||
<hui-theme-select-editor
|
||||
label="Theme (Optional)"
|
||||
.hass="${this.hass}"
|
||||
.value="${this._theme}"
|
||||
.configValue="${"theme"}"
|
||||
@theme-changed="${this._valueChanged}"
|
||||
></hui-theme-select-editor>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
@ -1110,6 +1110,9 @@
|
||||
"para_no_id": "This element doesn't have an ID. Please add an ID to this element in 'ui-lovelace.yaml'.",
|
||||
"para_migrate": "Home Assistant can add ID's to all your cards and views automatically for you by pressing the 'Migrate config' button.",
|
||||
"migrate": "Migrate config"
|
||||
},
|
||||
"theme": {
|
||||
"theme": "Theme (Optional)"
|
||||
}
|
||||
},
|
||||
"warning": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user