Do not color icon if too white

This commit is contained in:
Paulus Schoutsen 2015-11-15 00:36:35 -08:00
parent e550b0cec2
commit f2d9a4f071

View File

@ -16,9 +16,11 @@ export default new Polymer({
* Called when an attribute changes that influences the color of the icon.
*/
updateIconColor(newVal) {
// for domain light, set color of icon to light color if available
// for domain light, set color of icon to light color if available and it is
// not very white (sum rgb colors < 730)
if (newVal.domain === 'light' && newVal.state === 'on' &&
newVal.attributes.rgb_color) {
newVal.attributes.rgb_color &&
newVal.attributes.rgb_color.reduce((cur, tot) => cur + tot, 0) < 730) {
this.$.icon.style.color = 'rgb(' + newVal.attributes.rgb_color.join(',') + ')';
} else {
this.$.icon.style.color = null;