-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add picture card compatibility & exemple in gallery
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
title: Picture Card | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { html, LitElement, PropertyValues, TemplateResult } from "lit"; | ||
import { customElement, query } from "lit/decorators"; | ||
import { getEntity } from "../../../../src/fake_data/entity"; | ||
import { provideHass } from "../../../../src/fake_data/provide_hass"; | ||
import "../../components/demo-cards"; | ||
import { mockIcons } from "../../../../demo/src/stubs/icons"; | ||
|
||
const ENTITIES = [ | ||
getEntity("person", "paulus", "home", { | ||
friendly_name: "Paulus", | ||
entity_picture: "/images/paulus.jpg", | ||
}), | ||
]; | ||
|
||
const CONFIGS = [ | ||
{ | ||
heading: "Image URL", | ||
config: ` | ||
- type: picture | ||
image: /images/living_room.png | ||
`, | ||
}, | ||
{ | ||
heading: "Person entity", | ||
config: ` | ||
- type: picture | ||
image_entity: person.paulus | ||
`, | ||
}, | ||
{ | ||
heading: "Error: Image required", | ||
config: ` | ||
- type: picture | ||
entity: person.paulus | ||
`, | ||
}, | ||
]; | ||
|
||
@customElement("demo-lovelace-picture-card") | ||
class DemoPicture extends LitElement { | ||
@query("#demos") private _demoRoot!: HTMLElement; | ||
|
||
protected render(): TemplateResult { | ||
return html`<demo-cards id="demos" .configs=${CONFIGS}></demo-cards>`; | ||
} | ||
|
||
protected firstUpdated(changedProperties: PropertyValues) { | ||
super.firstUpdated(changedProperties); | ||
const hass = provideHass(this._demoRoot); | ||
hass.updateTranslations(null, "en"); | ||
hass.updateTranslations("lovelace", "en"); | ||
hass.addEntities(ENTITIES); | ||
mockIcons(hass); | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"demo-lovelace-picture-card": DemoPicture; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters