Inline domain icon (#1739)

This commit is contained in:
Paulus Schoutsen 2018-10-05 21:29:50 +02:00 committed by GitHub
parent 442375f76e
commit c90e13d35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 36 deletions

View File

@ -1,33 +0,0 @@
import '@polymer/iron-icon/iron-icon.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import domainIcon from '../common/entity/domain_icon.js';
class DomainIcon extends PolymerElement {
static get template() {
return html`
<iron-icon icon="[[computeIcon(domain, state)]]"></iron-icon>
`;
}
static get properties() {
return {
domain: {
type: String,
value: '',
},
state: {
type: String,
value: '',
},
};
}
computeIcon(domain, state) {
return domainIcon(domain, state);
}
}
customElements.define('domain-icon', DomainIcon);

View File

@ -1,12 +1,12 @@
import '@polymer/iron-flex-layout/iron-flex-layout-classes.js';
import '@polymer/iron-icon/iron-icon.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../../components/domain-icon.js';
import formatTime from '../../common/datetime/format_time.js';
import EventsMixin from '../../mixins/events-mixin.js';
import domainIcon from '../../common/entity/domain_icon.js';
/*
* @appliesMixin EventsMixin
@ -52,7 +52,7 @@ class HaLogbook extends EventsMixin(PolymerElement) {
<template is="dom-repeat" items="[[entries]]">
<div class="horizontal layout entry">
<div class="time">[[_formatTime(item.when)]]</div>
<domain-icon domain="[[item.domain]]" class="icon"></domain-icon>
<iron-icon icon="[[_computeIcon(item.domain)]]"></iron-icon>
<div class="message" flex="">
<template is="dom-if" if="[[!item.entity_id]]">
<span class="name">[[item.name]]</span>
@ -85,6 +85,10 @@ class HaLogbook extends EventsMixin(PolymerElement) {
return formatTime(new Date(date), this.language);
}
_computeIcon(domain) {
return domainIcon(domain);
}
entityClicked(ev) {
ev.preventDefault();
this.fire('hass-more-info', { entityId: ev.model.item.entity_id });