mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 12:46:35 +00:00
Align picture
card tap/hold actions (#2186)
Also removed unneccessary `navigation_path` config from `picture-entity`
This commit is contained in:
parent
5947bd6d74
commit
fb180c7b9b
@ -3,17 +3,17 @@ import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
|||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
|
||||||
import { LovelaceCard } from "../types";
|
import { LovelaceCard } from "../types";
|
||||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
|
||||||
import { navigate } from "../../../common/navigate";
|
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
import { classMap } from "lit-html/directives/classMap";
|
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 {
|
interface Config extends LovelaceCardConfig {
|
||||||
image?: string;
|
image?: string;
|
||||||
navigation_path?: string;
|
tap_action?: ActionConfig;
|
||||||
service?: string;
|
hold_action?: ActionConfig;
|
||||||
service_data?: object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HuiPictureCard extends LitElement implements LovelaceCard {
|
export class HuiPictureCard extends LitElement implements LovelaceCard {
|
||||||
@ -46,11 +46,13 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
|
|||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
<ha-card
|
<ha-card
|
||||||
@click="${this.handleClick}"
|
@ha-click="${this._handleTap}"
|
||||||
|
@ha-hold="${this._handleHold}"
|
||||||
|
.longPress="${longPress()}"
|
||||||
class="${
|
class="${
|
||||||
classMap({
|
classMap({
|
||||||
clickable: Boolean(
|
clickable: Boolean(
|
||||||
this._config.navigation_path || this._config.service
|
this._config.tap_action || this._config.hold_action
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
}"
|
}"
|
||||||
@ -77,14 +79,12 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClick(): void {
|
private _handleTap() {
|
||||||
if (this._config!.navigation_path) {
|
handleClick(this, this.hass!, this._config!, false);
|
||||||
navigate(this, this._config!.navigation_path!);
|
}
|
||||||
}
|
|
||||||
if (this._config!.service) {
|
private _handleHold() {
|
||||||
const [domain, service] = this._config!.service!.split(".", 2);
|
handleClick(this, this.hass!, this._config!, true);
|
||||||
this.hass!.callService(domain, service, this._config!.service_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import { UNAVAILABLE } from "../../../data/entity";
|
|||||||
interface Config extends LovelaceCardConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
navigation_path?: string;
|
|
||||||
image?: string;
|
image?: string;
|
||||||
camera_image?: string;
|
camera_image?: string;
|
||||||
state_image?: {};
|
state_image?: {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user