Skip to content

Commit

Permalink
feat: Add link support for entity names (#232)
Browse files Browse the repository at this point in the history
* Add link support for names

* Update src/label.ts

Co-authored-by: Petar Petrov <[email protected]>

* Update README.md

Co-authored-by: Petar Petrov <[email protected]>

---------

Co-authored-by: Petar Petrov <[email protected]>
  • Loading branch information
amaximus and MindFreeze authored Oct 4, 2024
1 parent f63239f commit a70811b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Install through [HACS](https://hacs.xyz/)
| color_limit | string | **Optional** | 1 | State value for coloring the box based on state value
| color_above | string | **Optional** | var(--paper-item-icon-color)| Color for state value above color_limit
| color_below | string | **Optional** | var(--primary-color)| Color for state value below color_limit
| url | string | **Optional** | | Specifying a URL will make the entity label into a link

| add_entities | list | **Optional** | | Experimental. List of entity ids. Their states will be added to this entity, showing a sum.
| subtract_entities | list | **Optional** | | Experimental. List of entity ids. Their states will be subtracted from this entity's state
| tap_action | action | **Optional** | more-info | Home assistant action to perform on tap. Supported action types are `more-info`, `zoom`, `navigate`, `url`, `toggle`, `call-service`, `fire-dom-event`
Expand Down
2 changes: 1 addition & 1 deletion src/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function renderLabel(
</span>`
: null}
${show_names
? html`${!vertical ? html`&nbsp;` : null}<span class="name" style=${styleMap(nameStyle)}>${name}</span>`
? html`${!vertical ? html`&nbsp;` : null}<span class="name" style=${styleMap(nameStyle)}>${!box.config.url ? html`${name}` : html`<a href="${box.config.url}" target="_blank">${name}</a>`}</span>`
: null}
</div>`;
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface EntityConfig {
color_above?: string;
color_below?: string;
color_limit?: number;
url?: string;
tap_action?: ActionConfigExtended;
double_tap_action?: ActionConfigExtended;
hold_action?: ActionConfigExtended;
Expand Down

0 comments on commit a70811b

Please sign in to comment.