Remove _hiddenState method. (#1557)

* Remove _hiddenState method since it always has the same result.

* Hide state when row element is narrow. Add input_number row to gallery.
This commit is contained in:
Jerad Meisner 2018-08-13 00:42:09 -07:00 committed by Paulus Schoutsen
parent 743c3ab784
commit 4bc83b01d3
2 changed files with 19 additions and 9 deletions

View File

@ -55,6 +55,15 @@ const ENTITIES = [
unit_of_measurement: '°F', unit_of_measurement: '°F',
friendly_name: 'Ecobee', friendly_name: 'Ecobee',
supported_features: 1014 supported_features: 1014
}),
getEntity('input_number', 'noise_allowance', 5, {
min: 0,
max: 10,
step: 1,
mode: 'slider',
unit_of_measurement: 'dB',
friendly_name: 'Allowed Noise',
icon: 'mdi:bell-ring'
}) })
]; ];
@ -72,6 +81,7 @@ const CONFIGS = [
- light.bed_light - light.bed_light
- light.non_existing - light.non_existing
- climate.ecobee - climate.ecobee
- input_number.noise_allowance
` `
}, },
{ {
@ -86,6 +96,7 @@ const CONFIGS = [
- lock.kitchen_door - lock.kitchen_door
- light.bed_light - light.bed_light
- climate.ecobee - climate.ecobee
- input_number.noise_allowance
title: Random group title: Random group
` `
}, },
@ -101,6 +112,7 @@ const CONFIGS = [
- lock.kitchen_door - lock.kitchen_door
- light.bed_light - light.bed_light
- climate.ecobee - climate.ecobee
- input_number.noise_allowance
title: Random group title: Random group
show_header_toggle: false show_header_toggle: false
` `
@ -130,6 +142,7 @@ const CONFIGS = [
- lock.kitchen_door - lock.kitchen_door
- light.bed_light - light.bed_light
- climate.ecobee - climate.ecobee
- input_number.noise_allowance
title: Random group title: Random group
show_header_toggle: false show_header_toggle: false
` `

View File

@ -40,7 +40,7 @@ class HuiInputNumberEntityRow extends mixinBehaviors([IronResizableBehavior], Po
on-change="_selectedValueChanged" on-change="_selectedValueChanged"
ignore-bar-touch ignore-bar-touch
></paper-slider> ></paper-slider>
<div class="state">[[_value]] [[_stateObj.attributes.unit_of_measurement]]</div> <span class="state">[[_value]] [[_stateObj.attributes.unit_of_measurement]]</span>
</div> </div>
</template> </template>
<template is="dom-if" if="[[_equals(_stateObj.attributes.mode, 'box')]]"> <template is="dom-if" if="[[_equals(_stateObj.attributes.mode, 'box')]]">
@ -113,14 +113,11 @@ class HuiInputNumberEntityRow extends mixinBehaviors([IronResizableBehavior], Po
} }
_hiddenState() { _hiddenState() {
if (this._stateObj.attributes.mode !== 'slider') return; if (!this.$ || this._stateObj.attributes.mode !== 'slider') return;
const sliderwidth = this.shadowRoot.querySelector('paper-slider').offsetWidth; const width = this.$.input_number_card.offsetWidth;
const stateElement = this.shadowRoot.querySelector('.state'); const stateEl = this.shadowRoot.querySelector('.state');
if (sliderwidth < 100) { if (!stateEl) return;
stateElement.style.display = 'none'; stateEl.hidden = width <= 350;
} else if (sliderwidth >= 145) {
stateElement.style.display = 'inline';
}
} }
_stateObjChanged(stateObj, oldStateObj) { _stateObjChanged(stateObj, oldStateObj) {