Cleanup of state-badge.html

pull/12/head
Paulus Schoutsen 2014-11-19 23:13:48 -08:00
parent 9656ff6636
commit cc4c557e89
2 changed files with 9 additions and 15 deletions

View File

@ -20,6 +20,7 @@
"core-item": "Polymer/core-item#~0.5.1", "core-item": "Polymer/core-item#~0.5.1",
"core-input": "Polymer/core-input#~0.5.1", "core-input": "Polymer/core-input#~0.5.1",
"core-icons": "polymer/core-icons#~0.5.1", "core-icons": "polymer/core-icons#~0.5.1",
"core-image": "polymer/core-image#~0.5.1",
"paper-toast": "Polymer/paper-toast#~0.5.1", "paper-toast": "Polymer/paper-toast#~0.5.1",
"paper-dialog": "Polymer/paper-dialog#~0.5.1", "paper-dialog": "Polymer/paper-dialog#~0.5.1",
"paper-spinner": "Polymer/paper-spinner#~0.5.1", "paper-spinner": "Polymer/paper-spinner#~0.5.1",

View File

@ -1,4 +1,5 @@
<link rel="import" href="bower_components/polymer/polymer.html"> <link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-image/core-image.html">
<link rel="import" href="domain-icon.html"> <link rel="import" href="domain-icon.html">
@ -20,7 +21,7 @@
text-align: center; text-align: center;
} }
#picture { core-image {
border-radius: 50%; border-radius: 50%;
} }
@ -40,7 +41,11 @@
domain="{{stateObj.domain}}" data-domain="{{stateObj.domain}}" domain="{{stateObj.domain}}" data-domain="{{stateObj.domain}}"
state="{{stateObj.state}}" data-state="{{stateObj.state}}"> state="{{stateObj.state}}" data-state="{{stateObj.state}}">
</domain-icon> </domain-icon>
<div fit id="picture"></div> <template if="{{stateObj.attributes.entity_picture}}">
<core-image
sizing="cover" fit
src="{{stateObj.attributes.entity_picture}}"></core-image>
</template>
</div> </div>
</template> </template>
@ -50,8 +55,7 @@
'stateObj.state': 'updateIconColor', 'stateObj.state': 'updateIconColor',
'stateObj.attributes.brightness': 'updateIconColor', 'stateObj.attributes.brightness': 'updateIconColor',
'stateObj.attributes.xy_color[0]': 'updateIconColor', 'stateObj.attributes.xy_color[0]': 'updateIconColor',
'stateObj.attributes.xy_color[1]': 'updateIconColor', 'stateObj.attributes.xy_color[1]': 'updateIconColor'
'stateObj.attributes.entity_picture': 'entityPictureChanged'
}, },
/** /**
@ -73,17 +77,6 @@
} }
}, },
/**
* Called when the attribute for entity_picture has changed.
*/
entityPictureChanged: function(oldVal, newVal) {
if(newVal) {
this.$.picture.style.backgroundImage = 'url(' + newVal + ')';
} else {
this.$.picture.style.backgroundImage = null;
}
},
// from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb // from http://stackoverflow.com/questions/22894498/philips-hue-convert-xy-from-api-to-hex-or-rgb
xyBriToRgb: function (x, y, bri) { xyBriToRgb: function (x, y, bri) {
z = 1.0 - x - y; z = 1.0 - x - y;