Add 'image' view.

This commit is contained in:
Dermot Duffy
2021-10-16 21:02:07 -07:00
parent 3c20352891
commit 0d7c20b550
11 changed files with 97 additions and 4 deletions
+26
View File
@@ -0,0 +1,26 @@
import { CSSResultGroup, LitElement, TemplateResult, html, unsafeCSS } from 'lit';
import { customElement, property } from 'lit/decorators';
import { dispatchMediaLoadEvent } from '../common';
import imageStyle from '../scss/image.scss';
import defaultImage from '../images/frigate-bird-in-sky.jpg'
@customElement('frigate-card-image')
export class FrigateCardImage extends LitElement {
@property({ attribute: false })
protected image?: string;
protected render(): TemplateResult | void {
return html` <img
src=${this.image || defaultImage}
@load=${(e) => {
dispatchMediaLoadEvent(this, e);
}}
>`;
}
static get styles(): CSSResultGroup {
return unsafeCSS(imageStyle);
}
}