Skip to content

Commit

Permalink
feat: use original key/source icon if none provided for custom one
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Aug 3, 2023
1 parent 4d33444 commit e437462
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Inside each button you may define `icon` and either `key`, `source` or `service`
| service | `_hass.callService(domain, service, service_data)` | A string representing service to call. Use the format `domain.service`, e.g. `"light.turn_on"` |
| service_data | passed with `service` | The data to pass to the service. May be an object depending on the service you are using. |

If an icon is not provided for a custom key or source that overwrites a predefined key or source, the original icon will be used instead.

## Custom icons

You can customize any icon with a custom svg path using the `custom_icons` option.
Expand Down Expand Up @@ -439,7 +441,6 @@ cards:
- keyboard
- enter
- search
```

Result:
Expand Down
7 changes: 7 additions & 0 deletions android-tv-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,13 @@ class TVCardServices extends LitElement {
let icon = info?.icon ?? '';
let svg_path = info.svg_path ?? this.custom_icons[icon] ?? '';

// Use original icon if none provided for custom key or source
if (!(icon || svg_path)) {
let info = defaultKeys[action] || defaultSources[action] || {};
icon = info?.icon ?? '';
svg_path = info?.svg_path ?? '';
}

// TODO: Use keypress event listener and a better way to pull up keyboard to send keyboard events to TV via ADB, have to translate from JS key code to ADB key code
// if (info.key == 'KEYBOARD') {
// document.addEventListener('keypress', (e) =>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "android-tv-card",
"version": "1.4.2",
"version": "1.4.3",
"description": "Android TV Remote Card",
"main": "./src/android-tv-card.js",
"scripts": {
Expand Down

0 comments on commit e437462

Please sign in to comment.