Lovelace: Style view backgroud (#1408)

* Lovelace: Style view backgroud

based on: #1403

fix: https://github.com/home-assistant/ui-schema/issues/30

```yaml
background: center / cover no-repeat url("https://images.pexels.com/photos/977736/pexels-photo-977736.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260")

background: radial-gradient(crimson, skyblue)

background: orange
```

* Reset background if not defined

* Simplify

* Lint

* Add global backround

* Fix backround in unused entities

* Lint
This commit is contained in:
c727 2018-07-06 21:12:43 +02:00 committed by Paulus Schoutsen
parent cb60904912
commit 10009eea2e
2 changed files with 6 additions and 1 deletions

View File

@ -198,6 +198,7 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) {
} }
let view; let view;
let background = this.config.background || '';
if (viewIndex === 'unused') { if (viewIndex === 'unused') {
view = document.createElement('hui-unused-entities'); view = document.createElement('hui-unused-entities');
@ -211,8 +212,11 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) {
view.config = viewConfig; view.config = viewConfig;
view.columns = this.columns; view.columns = this.columns;
} }
if (viewConfig.background) background = viewConfig.background;
} }
this.$.view.style.background = background;
view.hass = this.hass; view.hass = this.hass;
root.appendChild(view); root.appendChild(view);
} }

View File

@ -12,7 +12,8 @@ class HuiUnusedEntities extends PolymerElement {
<style> <style>
#root { #root {
max-width: 600px; max-width: 600px;
margin: 8px auto; margin: 0 auto;
padding: 8px 0;
} }
</style> </style>
<div id="root"></div> <div id="root"></div>