Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/panels/lovelace/entity-rows/hui-error-entity-row.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { html, LitElement } from "@polymer/lit-element";
import { TemplateResult } from "lit-html";

class HuiErrorEntityRow extends LitElement {
public entity?: string;

static get properties() {
return {
entity: {},
};
}

protected render(): TemplateResult {
if (!this.entity) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should always render this element, even if no entity set. Make it ${this.enttiy || ''} below and it's fine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also indirectly meant that we should remove this if, or else it doesn't make sense to default below.

return html``;
}

return html`
${this.renderStyle()}
<div>
Entity not available: ${this.entity}
</div>
`;
}

private renderStyle(): TemplateResult {
return html`
<style>
div {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, one more comment. Skip the whole div. Remove it from the template and update CSS to style :host

:host {
  display: block;
  background-color: yellow;
  padding: 8px;
}

btw do we know why we use flex: 1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I pulled that from somewhere and just kept the copypasta without checking any of it since it just worked. (Hearing that out loud sounds like I need to put the keyboard up smh)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not something I would ever do...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that we only work with the best engineers here 👍

Switch to :host was good, I removed the <div> as it is no longer needed.

@iantrich iantrich Nov 2, 2018

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, you brought on a C++ dev that started front-end stuff three months ago 🤣
I am very much the "well it works" crowd right now, but am trying to learn the why as well.

flex: 1;
background-color: yellow;
padding: 8px;
}
</style>
`;
}
}

declare global {
interface HTMLElementTagNameMap {
"hui-error-entity-row": HuiErrorEntityRow;
}
}

customElements.define("hui-error-entity-row", HuiErrorEntityRow);