Skip to content

Commit

Permalink
Add icon option for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Jul 7, 2020
1 parent 6a8f2d4 commit 634ce0a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ views:
- cards:
- type: custom:roku-card
entity: media_player.office_roku
tv: true
apps:
- app: Netflix
icon: mdi:netflix
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Use [HACS](https://hacs.xyz) or follow this [guide](https://github.com/thomaslov

```yaml
resources:
url: /local/roku-card.js
type: module
url: /local/roku-card.js
type: module
```
## Options
Expand Down Expand Up @@ -68,6 +68,7 @@ resources:
| ----------------- | -------- | ------------ | ----------------------------------------------------------- |
| app | `string` | **Optional** | Name of the source to launch as `tap_action` |
| image | `string` | **Optional** | Path to image to use for app |
| icon | `string` | **Optional** | mdi icon to use instead of an image for app |
| tap_action | `map` | **Optional** | Tap action map [See action options](#action-options) |
| hold_action | `map` | **Optional** | Hold action map [See action options](#action-options) |
| double_tap_action | `map` | **Optional** | Doulbe Tap action map [See action options](#action-options) |
Expand Down Expand Up @@ -97,7 +98,7 @@ resources:
## Usage

```yaml
type: "custom:roku-card"
type: 'custom:roku-card'
entity: media_player.basement_roku
tv: true
apps:
Expand Down Expand Up @@ -139,7 +140,7 @@ volume_down:
`resources:`

```yaml
- url: "http://127.0.0.1:5000/roku-card.js"
- url: 'http://127.0.0.1:5000/roku-card.js'
type: module
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roku-card",
"version": "1.1.3",
"version": "1.1.4",
"description": "Lovelace Roku Card",
"keywords": [
"home-assistant",
Expand Down Expand Up @@ -48,4 +48,4 @@
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
}
}
}
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CARD_VERSION = '1.1.3';
export const CARD_VERSION = '1.1.4';
37 changes: 25 additions & 12 deletions src/roku-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,31 @@ export class RokuCard extends LitElement {

private _renderImage(index: number): TemplateResult {
return this._config && this._config.apps && this._config.apps.length > index
? html`
<img
src=${this._config.apps[index].image || ''}
.app=${this._config.apps[index].app}
.config=${this._config.apps[index]}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.apps[index].hold_action),
hasDoubleClick: hasAction(this._config.apps[index].double_tap_action),
})}
/>
`
? this._config.apps[index].icon
? html`
<ha-icon-button
.app=${this._config.apps[index].app}
icon=${this._config.apps[index].icon!}
title=${this._config.apps[index].app!}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.apps[index].hold_action),
hasDoubleClick: hasAction(this._config.apps[index].double_tap_action),
})}
></ha-icon-button>
`
: html`
<img
src=${this._config.apps[index].image || ''}
.app=${this._config.apps[index].app}
.config=${this._config.apps[index]}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.apps[index].hold_action),
hasDoubleClick: hasAction(this._config.apps[index].double_tap_action),
})}
/>
`
: html` <ha-icon-button></ha-icon-button> `;
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface ActionButtonConfig {
export interface AppConfig {
app?: string;
image?: string;
icon?: string;
tap_action?: ActionConfig;
hold_action?: ActionConfig;
double_tap_action?: ActionConfig;
Expand Down

0 comments on commit 634ce0a

Please sign in to comment.