mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-24 17:57:14 +00:00
custom panel example: update to polymer 2 class (#3693)
This commit is contained in:
parent
f2ec8c291f
commit
39c2487cf0
@ -28,38 +28,38 @@ 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: {
|
|
||||||
// Home Assistant object
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
// If should render in narrow mode
|
|
||||||
narrow: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
// If sidebar is currently shown
|
|
||||||
showMenu: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
// Home Assistant panel info
|
|
||||||
// panel.config contains config passed to register_panel serverside
|
|
||||||
panel: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
who: {
|
|
||||||
type: String,
|
|
||||||
computed: 'computeWho(panel)',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computeWho: function (panel) {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
// Home Assistant object
|
||||||
|
hass: Object,
|
||||||
|
// If should render in narrow mode
|
||||||
|
narrow: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
// If sidebar is currently shown
|
||||||
|
showMenu: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
// Home Assistant panel info
|
||||||
|
// panel.config contains config passed to register_panel serverside
|
||||||
|
panel: Object,
|
||||||
|
who: {
|
||||||
|
type: String,
|
||||||
|
computed: 'computeWho(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>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user