Skip to content

Commit

Permalink
Added hold and double tap actions for tile card icon (#21947)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindybal authored Sep 13, 2024
1 parent 9078ab4 commit 68a0d04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
const config = {
entity: this._config!.entity,
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 {
Expand Down Expand Up @@ -286,7 +288,10 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
role=${ifDefined(this.hasIconAction ? "button" : undefined)}
tabindex=${ifDefined(this.hasIconAction ? "0" : undefined)}
@action=${this._handleIconAction}
.actionHandler=${actionHandler()}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config!.icon_hold_action),
hasDoubleClick: hasAction(this._config!.icon_double_tap_action),
})}
>
${imageUrl
? html`
Expand Down
2 changes: 2 additions & 0 deletions src/panels/lovelace/cards/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,5 +498,7 @@ export interface TileCardConfig extends LovelaceCardConfig {
hold_action?: ActionConfig;
double_tap_action?: ActionConfig;
icon_tap_action?: ActionConfig;
icon_hold_action?: ActionConfig;
icon_double_tap_action?: ActionConfig;
features?: LovelaceCardFeatureConfig[];
}

0 comments on commit 68a0d04

Please sign in to comment.