Added hold and double tap actions for tile card icon (#21947)

This commit is contained in:
Martin Dybal 2024-09-13 09:59:04 +02:00 committed by GitHub
parent 9078ab4026
commit 68a0d04f04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -136,8 +136,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
const config = { const config = {
entity: this._config!.entity, entity: this._config!.entity,
tap_action: this._config!.icon_tap_action, tap_action: this._config!.icon_tap_action,
hold_action: this._config!.icon_hold_action,
double_tap_action: this._config!.icon_double_tap_action,
}; };
handleAction(this, this.hass!, config, "tap"); handleAction(this, this.hass!, config, ev.detail.action!);
} }
private _getImageUrl(entity: HassEntity): string | undefined { private _getImageUrl(entity: HassEntity): string | undefined {
@ -286,7 +288,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
role=${ifDefined(this.hasIconAction ? "button" : undefined)} role=${ifDefined(this.hasIconAction ? "button" : undefined)}
tabindex=${ifDefined(this.hasIconAction ? "0" : undefined)} tabindex=${ifDefined(this.hasIconAction ? "0" : undefined)}
@action=${this._handleIconAction} @action=${this._handleIconAction}
.actionHandler=${actionHandler()} .actionHandler=${actionHandler({
hasHold: hasAction(this._config!.icon_hold_action),
hasDoubleClick: hasAction(this._config!.icon_double_tap_action),
})}
> >
${imageUrl ${imageUrl
? html` ? html`

View File

@ -498,5 +498,7 @@ export interface TileCardConfig extends LovelaceCardConfig {
hold_action?: ActionConfig; hold_action?: ActionConfig;
double_tap_action?: ActionConfig; double_tap_action?: ActionConfig;
icon_tap_action?: ActionConfig; icon_tap_action?: ActionConfig;
icon_hold_action?: ActionConfig;
icon_double_tap_action?: ActionConfig;
features?: LovelaceCardFeatureConfig[]; features?: LovelaceCardFeatureConfig[];
} }