-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add entity row that displays static text #5516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { | ||
| html, | ||
| LitElement, | ||
| TemplateResult, | ||
| customElement, | ||
| property, | ||
| css, | ||
| CSSResult, | ||
| } from "lit-element"; | ||
|
|
||
| import { LovelaceRow, TextConfig } from "../entity-rows/types"; | ||
|
|
||
| import "../../../components/ha-icon"; | ||
|
|
||
| @customElement("hui-text-row") | ||
| class HuiTextRow extends LitElement implements LovelaceRow { | ||
| @property() private _config?: TextConfig; | ||
|
|
||
| public setConfig(config: TextConfig): void { | ||
| if (!config || !config.name || !config.text) { | ||
| throw new Error("Invalid Configuration: 'name' and 'text' required"); | ||
| } | ||
|
|
||
| this._config = config; | ||
| } | ||
|
|
||
| protected render(): TemplateResult { | ||
| if (!this._config) { | ||
| return html``; | ||
| } | ||
|
|
||
| return html` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just use the generic row here to keep it the same as the others? Lest maintenance if it changes?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generic row relies on an entity.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah didnt realize |
||
| <ha-icon .icon="${this._config.icon}"></ha-icon> | ||
| <div class="name">${this._config.name}</div> | ||
| <div class="text">${this._config.text}</div> | ||
| `; | ||
| } | ||
|
|
||
| static get styles(): CSSResult { | ||
| return css` | ||
| :host { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| ha-icon { | ||
| padding: 8px; | ||
| color: var(--paper-item-icon-color); | ||
| } | ||
| div { | ||
| flex: 1; | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
| .name { | ||
| margin-left: 16px; | ||
| } | ||
| .text { | ||
| text-align: right; | ||
| } | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "hui-text-row": HuiTextRow; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to Lazy load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lazy load is the default. Only ones that are super popular should be considered to be bundled. Requires an editor too.