🔨 Fix for element positioning (#2335)

* Fix for element positioning

* Address comments
This commit is contained in:
Ian Richardson 2018-12-17 03:07:59 -06:00 committed by Paulus Schoutsen
parent e5bf842801
commit b7c34c483a
2 changed files with 59 additions and 10 deletions

View File

@ -76,6 +76,55 @@ const CONFIGS = [
left: 35%
`,
},
{
heading: "Card with header",
config: `
- type: picture-elements
image: /images/floorplan.png
title: My House
elements:
- type: service-button
title: Lights Off
style:
top: 97%
left: 90%
padding: 0px
service: light.turn_off
service_data:
entity_id: group.all_lights
- type: icon
icon: mdi:cctv
entity: camera.demo_camera
style:
top: 12%
left: 6%
transform: rotate(-60deg) scaleX(-1)
--iron-icon-height: 30px
--iron-icon-width: 30px
--iron-icon-stroke-color: black
--iron-icon-fill-color: rgba(50, 50, 50, .75)
- type: image
entity: light.bed_light
tap_action:
action: toggle
image: /images/light_bulb_off.png
state_image:
'on': /images/light_bulb_on.png
state_filter:
'on': brightness(130%) saturate(1.5) drop-shadow(0px 0px 10px gold)
'off': brightness(80%) saturate(0.8)
style:
top: 35%
left: 65%
width: 7%
padding: 50px 50px 100px 50px
- type: state-icon
entity: binary_sensor.movement_backyard
style:
top: 8%
left: 35%
`,
},
];
class DemoPicElements extends PolymerElement {

View File

@ -63,6 +63,7 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
return html`
${this.renderStyle()}
<ha-card .header="${this._config.title}">
<div id="root">
<hui-image
.hass="${this._hass}"
.image="${this._config.image}"
@ -71,7 +72,6 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
.entity="${this._config.entity}"
.aspectRatio="${this._config.aspect_ratio}"
></hui-image>
<div id="root">
${
this._config.elements.map((elementConfig: LovelaceElementConfig) =>
this._createHuiElement(elementConfig)
@ -85,9 +85,9 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard {
private renderStyle(): TemplateResult {
return html`
<style>
ha-card {
overflow: hidden;
#root {
position: relative;
overflow: hidden;
}
.element {
position: absolute;