Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/panels/lovelace/cards/hui-picture-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
import "../../../components/ha-card";

import { LovelaceCard } from "../types";
import { LovelaceCardConfig } from "../../../data/lovelace";
import { navigate } from "../../../common/navigate";
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
import { HomeAssistant } from "../../../types";
import { TemplateResult } from "lit-html";
import { classMap } from "lit-html/directives/classMap";
import { handleClick } from "../common/handle-click";
import { longPress } from "../common/directives/long-press-directive";

interface Config extends LovelaceCardConfig {
image?: string;
navigation_path?: string;
service?: string;
service_data?: object;
tap_action?: ActionConfig;
hold_action?: ActionConfig;
}

export class HuiPictureCard extends LitElement implements LovelaceCard {
Expand Down Expand Up @@ -46,11 +46,13 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
return html`
${this.renderStyle()}
<ha-card
@click="${this.handleClick}"
@ha-click="${this._handleTap}"
@ha-hold="${this._handleHold}"
.longPress="${longPress()}"
class="${
classMap({
clickable: Boolean(
this._config.navigation_path || this._config.service
this._config.tap_action || this._config.hold_action
),
})
}"
Expand All @@ -77,14 +79,12 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
`;
}

private handleClick(): void {
if (this._config!.navigation_path) {
navigate(this, this._config!.navigation_path!);
}
if (this._config!.service) {
const [domain, service] = this._config!.service!.split(".", 2);
this.hass!.callService(domain, service, this._config!.service_data);
}
private _handleTap() {
handleClick(this, this.hass!, this._config!, false);
}

private _handleHold() {
handleClick(this, this.hass!, this._config!, true);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/panels/lovelace/cards/hui-picture-entity-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { UNAVAILABLE } from "../../../data/entity";
interface Config extends LovelaceCardConfig {
entity: string;
name?: string;
navigation_path?: string;
image?: string;
camera_image?: string;
state_image?: {};
Expand Down