Skip to content

Commit

Permalink
use generateColorTemperatureGradient
Browse files Browse the repository at this point in the history
  • Loading branch information
schelv committed Oct 30, 2023
1 parent a50aa8d commit 9a0d1ae
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/components/ha-selector/ha-selector-color-temp.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { css, html, LitElement } from "lit";
import { html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
import type { ColorTempSelector } from "../../data/selector";
import type { HomeAssistant } from "../../types";
import "../ha-labeled-slider";
import { styleMap } from "lit/directives/style-map";
import { generateColorTemperatureGradient } from "../../dialogs/more-info/components/lights/light-color-temp-picker";
import memoizeOne from "memoize-one";
import { mired2kelvin } from "../../common/color/convert-light-color";

@customElement("ha-selector-color_temp")
Expand All @@ -31,9 +31,6 @@ export class HaColorTempSelector extends LitElement {


const gradient = this._generateTemperatureGradient(min, max);
// const firstPercentage = (100 * (153 - min)) / 173.5;
// const secondPercentage = (50 * (153 - min + 500 - max)) / 173.5 + 50;
// const thirdPercentage = (100 * (500 - max)) / 173.5 + 100;

return html`
<ha-labeled-slider
Expand All @@ -56,25 +53,14 @@ export class HaColorTempSelector extends LitElement {
}

private _generateTemperatureGradient = memoizeOne(
(min: number, max: number) => generateColorTemperatureGradient(mired2kelvin(max), mired2kelvin(min))
(min: number, max: number) => generateColorTemperatureGradient(mired2kelvin(min), mired2kelvin(max))
);

private _valueChanged(ev: CustomEvent) {
fireEvent(this, "value-changed", {
value: Number((ev.detail as any).value),
});
}

// static styles = css`
// ha-labeled-slider {
// --ha-slider-background: linear-gradient(
// to var(--float-end),
// rgb(255, 160, 0) var(--first-percentage),
// white var(--second-percentage),
// rgb(166, 209, 255) var(--third-percentage)
// );
// }
// `;
}

declare global {
Expand Down

0 comments on commit 9a0d1ae

Please sign in to comment.