Skip to content

Commit

Permalink
Rename tooltipUnit to unit for slider (#18599)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Nov 10, 2023
1 parent d3f6ebd commit 1d45cb7
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gallery/src/pages/components/ha-control-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class DemoHaBarSlider extends LitElement {
@value-changed=${this.handleValueChanged}
@slider-moved=${this.handleSliderMoved}
aria-labelledby=${id}
.tooltipUnit=${config.unit}
.unit=${config.unit}
>
</ha-control-slider>
</div>
Expand All @@ -119,7 +119,7 @@ export class DemoHaBarSlider extends LitElement {
@value-changed=${this.handleValueChanged}
@slider-moved=${this.handleSliderMoved}
aria-label=${label}
.tooltipUnit=${config.unit}
.unit=${config.unit}
>
</ha-control-slider>
`;
Expand Down
8 changes: 4 additions & 4 deletions src/components/ha-control-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class HaControlSlider extends LitElement {
@property({ attribute: "tooltip-position" })
public tooltipPosition?: TooltipPosition;

@property({ attribute: "tooltip-unit" })
public tooltipUnit?: string;
@property()
public unit?: string;

@property({ attribute: "tooltip-mode" })
public tooltipMode: TooltipMode = "interaction";
Expand Down Expand Up @@ -292,8 +292,8 @@ export class HaControlSlider extends LitElement {
private _formatValue(value: number) {
const formattedValue = formatNumber(value, this.locale);

const formattedUnit = this.tooltipUnit
? `${blankBeforeUnit(this.tooltipUnit, this.locale)}${this.tooltipUnit}`
const formattedUnit = this.unit
? `${blankBeforeUnit(this.unit, this.locale)}${this.unit}`
: "";

return `${formattedValue}${formattedUnit}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class HaMoreInfoCoverPosition extends LitElement {
"--control-slider-background": color,
})}
.disabled=${this.stateObj.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_position}
.unit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_position}
.locale=${this.hass.locale}
>
</ha-control-slider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class HaMoreInfoCoverTiltPosition extends LitElement {
"--control-slider-background": color,
})}
.disabled=${this.stateObj.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_tilt_position}
.unit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_tilt_position}
.locale=${this.hass.locale}
>
<div slot="background" class="gradient"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class HaMoreInfoFanSpeed extends LitElement {
"--control-slider-background": color,
})}
.disabled=${this.stateObj.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.fan.percentage}
.unit=${DOMAIN_ATTRIBUTES_UNITS.fan.percentage}
.locale=${this.hass.locale}
>
</ha-control-slider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class HaMoreInfoLightBrightness extends LitElement {
"--control-slider-background": color,
})}
.disabled=${this.stateObj.state === UNAVAILABLE}
.tooltipUnit=${"%"}
unit="%"
.locale=${this.hass.locale}
>
</ha-control-slider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class LightColorTempPicker extends LitElement {
"--gradient": gradient,
})}
.disabled=${this.stateObj.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.light.color_temp_kelvin}
.unit=${DOMAIN_ATTRIBUTES_UNITS.light.color_temp_kelvin}
.locale=${this.hass.locale}
>
</ha-control-slider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class HuiCoverPositionTileFeature
"current_position"
)}
.disabled=${this.stateObj!.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_position}
.unit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_position}
.locale=${this.hass.locale}
></ha-control-slider>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class HuiCoverTiltPositionTileFeature
"current_tilt_position"
)}
.disabled=${this.stateObj!.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_tilt_position}
.unit=${DOMAIN_ATTRIBUTES_UNITS.cover.current_tilt_position}
.locale=${this.hass.locale}
>
<div slot="background" class="gradient"></div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class HuiFanSpeedTileFeature extends LitElement implements LovelaceTileFeature {
"percentage"
)}
.disabled=${this.stateObj!.state === UNAVAILABLE}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.fan.percentage}
.unit=${DOMAIN_ATTRIBUTES_UNITS.fan.percentage}
.locale=${this.hass.locale}
></ha-control-slider>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class HuiLightBrightnessTileFeature
.disabled=${this.stateObj!.state === UNAVAILABLE}
@value-changed=${this._valueChanged}
.label=${this.hass.localize("ui.card.light.brightness")}
.tooltipUnit=${"%"}
unit="%"
.locale=${this.hass.locale}
></ha-control-slider>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class HuiLightColorTempTileFeature
style=${styleMap({
"--gradient": gradient,
})}
.tooltipUnit=${DOMAIN_ATTRIBUTES_UNITS.light.color_temp_kelvin}
.unit=${DOMAIN_ATTRIBUTES_UNITS.light.color_temp_kelvin}
.locale=${this.hass.locale}
></ha-control-slider>
</div>
Expand Down

0 comments on commit 1d45cb7

Please sign in to comment.