custom panel example: update to polymer 2 class (#3693)

This commit is contained in:
c727 2017-10-21 17:36:29 +02:00 committed by Fabian Affolter
parent f2ec8c291f
commit 39c2487cf0

View File

@ -28,13 +28,13 @@ The `hello.html` contains the needed building blocks to create the elements insi
</dom-module> </dom-module>
<script> <script>
Polymer({ class HaPanelHello extends Polymer.Element {
is: 'ha-panel-hello', static get is() { return 'ha-panel-hello'; }
properties: {
static get properties() {
return {
// Home Assistant object // Home Assistant object
hass: { hass: Object,
type: Object,
},
// If should render in narrow mode // If should render in narrow mode
narrow: { narrow: {
type: Boolean, type: Boolean,
@ -47,19 +47,19 @@ Polymer({
}, },
// Home Assistant panel info // Home Assistant panel info
// panel.config contains config passed to register_panel serverside // panel.config contains config passed to register_panel serverside
panel: { panel: Object,
type: Object,
},
who: { who: {
type: String, type: String,
computed: 'computeWho(panel)', computed: 'computeWho(panel)',
},
};
} }
},
computeWho: function (panel) { computeWho(panel) {
return panel && panel.config && panel.config.who ? panel.config.who : 'World'; return panel && panel.config && panel.config.who ? panel.config.who : 'World';
}, }
}); }
customElements.define(HaPanelHello.is, HaPanelHello);
</script> </script>
``` ```