mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Color picker: dynamic segmentation (#2806)
* Color picker: dynamic segmentation * Color Picker: dynamic segmentation * Color Picker: dynamic segments * == --> === * spaces * use setProperties() * fix dynamic segements * Change size position and collor of segmentation button * add spaces * Add ;
This commit is contained in:
parent
8c23674683
commit
6580d4ce92
@ -140,6 +140,7 @@ class HaColorPicker extends EventsMixin(PolymerElement) {
|
|||||||
hueSegments: {
|
hueSegments: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0,
|
value: 0,
|
||||||
|
observer: "segmentationChange",
|
||||||
},
|
},
|
||||||
|
|
||||||
// the amount segments for the hue
|
// the amount segments for the hue
|
||||||
@ -149,6 +150,7 @@ class HaColorPicker extends EventsMixin(PolymerElement) {
|
|||||||
saturationSegments: {
|
saturationSegments: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0,
|
value: 0,
|
||||||
|
observer: "segmentationChange",
|
||||||
},
|
},
|
||||||
|
|
||||||
// set to true to make the segments purely esthetical
|
// set to true to make the segments purely esthetical
|
||||||
@ -590,5 +592,11 @@ class HaColorPicker extends EventsMixin(PolymerElement) {
|
|||||||
this.tooltip = svgElement.tooltip;
|
this.tooltip = svgElement.tooltip;
|
||||||
svgElement.appendChild(svgElement.tooltip);
|
svgElement.appendChild(svgElement.tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
segmentationChange() {
|
||||||
|
if (this.backgroundLayer) {
|
||||||
|
this.drawColorWheel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
customElements.define("ha-color-picker", HaColorPicker);
|
customElements.define("ha-color-picker", HaColorPicker);
|
||||||
|
@ -48,6 +48,11 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
--paper-slider-knob-start-border-color: var(--primary-color);
|
--paper-slider-knob-start-border-color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.segmentationContainer {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
ha-color-picker {
|
ha-color-picker {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -57,6 +62,29 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
transition: max-height 0.5s ease-in;
|
transition: max-height 0.5s ease-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.segmentationButton {
|
||||||
|
position: absolute;
|
||||||
|
top: 11%;
|
||||||
|
transform: translate(0%, 0%);
|
||||||
|
padding: 0px;
|
||||||
|
max-height: 0px;
|
||||||
|
width: 23px;
|
||||||
|
height: 23px;
|
||||||
|
opacity: var(--dark-secondary-opacity);
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 0.5s ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-color.is-on .segmentationContainer .segmentationButton {
|
||||||
|
position: absolute;
|
||||||
|
top: 11%;
|
||||||
|
transform: translate(0%, 0%);
|
||||||
|
width: 23px;
|
||||||
|
height: 23px;
|
||||||
|
padding: 0px;
|
||||||
|
opacity: var(--dark-secondary-opacity);
|
||||||
|
}
|
||||||
|
|
||||||
.has-effect_list.is-on .effect_list,
|
.has-effect_list.is-on .effect_list,
|
||||||
.has-brightness .brightness,
|
.has-brightness .brightness,
|
||||||
.has-color_temp.is-on .color_temp,
|
.has-color_temp.is-on .color_temp,
|
||||||
@ -75,6 +103,11 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.has-color.is-on .segmentationButton {
|
||||||
|
max-height: 100px;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
.has-color.is-on ha-color-picker {
|
.has-color.is-on ha-color-picker {
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
@ -126,16 +159,22 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
on-change="wvSliderChanged"
|
on-change="wvSliderChanged"
|
||||||
></ha-labeled-slider>
|
></ha-labeled-slider>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="segmentationContainer">
|
||||||
<ha-color-picker
|
<ha-color-picker
|
||||||
class="control color"
|
class="control color"
|
||||||
on-colorselected="colorPicked"
|
on-colorselected="colorPicked"
|
||||||
desired-hs-color="{{colorPickerColor}}"
|
desired-hs-color="{{colorPickerColor}}"
|
||||||
throttle="500"
|
throttle="500"
|
||||||
hue-segments="24"
|
hue-segments="{{hueSegments}}"
|
||||||
saturation-segments="8"
|
saturation-segments="{{saturationSegments}}"
|
||||||
>
|
>
|
||||||
</ha-color-picker>
|
</ha-color-picker>
|
||||||
|
<paper-icon-button
|
||||||
|
icon="mdi:palette"
|
||||||
|
on-click="segmentClick"
|
||||||
|
class="control segmentationButton"
|
||||||
|
></paper-icon-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="control effect_list">
|
<div class="control effect_list">
|
||||||
<paper-dropdown-menu
|
<paper-dropdown-menu
|
||||||
@ -194,6 +233,16 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hueSegments: {
|
||||||
|
type: Number,
|
||||||
|
value: 24,
|
||||||
|
},
|
||||||
|
|
||||||
|
saturationSegments: {
|
||||||
|
type: Number,
|
||||||
|
value: 8,
|
||||||
|
},
|
||||||
|
|
||||||
colorPickerColor: {
|
colorPickerColor: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
@ -291,6 +340,14 @@ class MoreInfoLight extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
segmentClick() {
|
||||||
|
if (this.hueSegments === 24 && this.saturationSegments === 8) {
|
||||||
|
this.setProperties({ hueSegments: 0, saturationSegments: 0 });
|
||||||
|
} else {
|
||||||
|
this.setProperties({ hueSegments: 24, saturationSegments: 8 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
serviceChangeColor(hass, entityId, color) {
|
serviceChangeColor(hass, entityId, color) {
|
||||||
hass.callService("light", "turn_on", {
|
hass.callService("light", "turn_on", {
|
||||||
entity_id: entityId,
|
entity_id: entityId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user