Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions demo/src/stubs/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ export const mockTemplate = (hass: MockHomeAssistant) => {
body: { message: "Template dev tool does not work in the demo." },
})
);
hass.mockWS("render_template", (msg, onChange) => {
onChange!({
result: msg.template,
listeners: { all: false, domains: [], entities: [], time: false },
});
return () => {};
});
};
10 changes: 9 additions & 1 deletion gallery/src/demos/demo-hui-markdown-card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import { mockTemplate } from "../../../demo/src/stubs/template";
import { provideHass } from "../../../src/fake_data/provide_hass";
import "../components/demo-cards";

const CONFIGS = [
Expand Down Expand Up @@ -254,7 +256,7 @@ const CONFIGS = [

class DemoMarkdown extends PolymerElement {
static get template() {
return html` <demo-cards configs="[[_configs]]"></demo-cards> `;
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
}

static get properties() {
Expand All @@ -265,6 +267,12 @@ class DemoMarkdown extends PolymerElement {
},
};
}

public ready() {
super.ready();
const hass = provideHass(this.$.demos);
mockTemplate(hass);
}
}

customElements.define("demo-hui-markdown-card", DemoMarkdown);