mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-02 00:27:49 +01:00
Deduplicate favorite card feature editors
This commit is contained in:
@@ -1,41 +1,12 @@
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../components/ha-alert";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type {
|
||||
CoverPositionFavoriteCardFeatureConfig,
|
||||
LovelaceCardFeatureContext,
|
||||
} from "../../card-features/types";
|
||||
import type { LovelaceCardFeatureEditor } from "../../types";
|
||||
import { customElement } from "lit/decorators";
|
||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||
import type { CoverPositionFavoriteCardFeatureConfig } from "../../card-features/types";
|
||||
import { HuiFavoriteCardFeatureEditorBase } from "./hui-favorite-card-feature-editor-base";
|
||||
|
||||
@customElement("hui-cover-position-favorite-card-feature-editor")
|
||||
export class HuiCoverPositionFavoriteCardFeatureEditor
|
||||
extends LitElement
|
||||
implements LovelaceCardFeatureEditor
|
||||
{
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state() private _config?: CoverPositionFavoriteCardFeatureConfig;
|
||||
|
||||
public setConfig(config: CoverPositionFavoriteCardFeatureConfig): void {
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.features.types.cover-position-favorite.description"
|
||||
)}
|
||||
</ha-alert>
|
||||
`;
|
||||
}
|
||||
export class HuiCoverPositionFavoriteCardFeatureEditor extends HuiFavoriteCardFeatureEditorBase<CoverPositionFavoriteCardFeatureConfig> {
|
||||
protected readonly _descriptionKey =
|
||||
"ui.panel.lovelace.editor.features.types.cover-position-favorite.description" satisfies LocalizeKeys;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,41 +1,12 @@
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../components/ha-alert";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type {
|
||||
CoverTiltFavoriteCardFeatureConfig,
|
||||
LovelaceCardFeatureContext,
|
||||
} from "../../card-features/types";
|
||||
import type { LovelaceCardFeatureEditor } from "../../types";
|
||||
import { customElement } from "lit/decorators";
|
||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||
import type { CoverTiltFavoriteCardFeatureConfig } from "../../card-features/types";
|
||||
import { HuiFavoriteCardFeatureEditorBase } from "./hui-favorite-card-feature-editor-base";
|
||||
|
||||
@customElement("hui-cover-tilt-favorite-card-feature-editor")
|
||||
export class HuiCoverTiltFavoriteCardFeatureEditor
|
||||
extends LitElement
|
||||
implements LovelaceCardFeatureEditor
|
||||
{
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state() private _config?: CoverTiltFavoriteCardFeatureConfig;
|
||||
|
||||
public setConfig(config: CoverTiltFavoriteCardFeatureConfig): void {
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.features.types.cover-tilt-favorite.description"
|
||||
)}
|
||||
</ha-alert>
|
||||
`;
|
||||
}
|
||||
export class HuiCoverTiltFavoriteCardFeatureEditor extends HuiFavoriteCardFeatureEditorBase<CoverTiltFavoriteCardFeatureConfig> {
|
||||
protected readonly _descriptionKey =
|
||||
"ui.panel.lovelace.editor.features.types.cover-tilt-favorite.description" satisfies LocalizeKeys;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-alert";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type {
|
||||
LovelaceCardFeatureConfig,
|
||||
LovelaceCardFeatureContext,
|
||||
} from "../../card-features/types";
|
||||
import type { LovelaceCardFeatureEditor } from "../../types";
|
||||
|
||||
export abstract class HuiFavoriteCardFeatureEditorBase<
|
||||
TConfig extends LovelaceCardFeatureConfig,
|
||||
>
|
||||
extends LitElement
|
||||
implements LovelaceCardFeatureEditor
|
||||
{
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state() private _config?: TConfig;
|
||||
|
||||
protected abstract readonly _descriptionKey: LocalizeKeys;
|
||||
|
||||
public setConfig(config: TConfig): void {
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(this._descriptionKey)}
|
||||
</ha-alert>
|
||||
`;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,12 @@
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../../components/ha-alert";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type {
|
||||
LovelaceCardFeatureContext,
|
||||
ValvePositionFavoriteCardFeatureConfig,
|
||||
} from "../../card-features/types";
|
||||
import type { LovelaceCardFeatureEditor } from "../../types";
|
||||
import { customElement } from "lit/decorators";
|
||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||
import type { ValvePositionFavoriteCardFeatureConfig } from "../../card-features/types";
|
||||
import { HuiFavoriteCardFeatureEditorBase } from "./hui-favorite-card-feature-editor-base";
|
||||
|
||||
@customElement("hui-valve-position-favorite-card-feature-editor")
|
||||
export class HuiValvePositionFavoriteCardFeatureEditor
|
||||
extends LitElement
|
||||
implements LovelaceCardFeatureEditor
|
||||
{
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state() private _config?: ValvePositionFavoriteCardFeatureConfig;
|
||||
|
||||
public setConfig(config: ValvePositionFavoriteCardFeatureConfig): void {
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.features.types.valve-position-favorite.description"
|
||||
)}
|
||||
</ha-alert>
|
||||
`;
|
||||
}
|
||||
export class HuiValvePositionFavoriteCardFeatureEditor extends HuiFavoriteCardFeatureEditorBase<ValvePositionFavoriteCardFeatureConfig> {
|
||||
protected readonly _descriptionKey =
|
||||
"ui.panel.lovelace.editor.features.types.valve-position-favorite.description" satisfies LocalizeKeys;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
Reference in New Issue
Block a user