Skip to content

Commit

Permalink
Add tooltip to tile sliders and more info sliders (#18567)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Nov 8, 2023
1 parent f2505c0 commit bc21425
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 134 deletions.
6 changes: 6 additions & 0 deletions gallery/src/pages/components/ha-control-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const sliders: {
id: string;
label: string;
mode?: "start" | "end" | "cursor";
unit?: string;
class?: string;
}[] = [
{
Expand All @@ -31,18 +32,21 @@ const sliders: {
label: "Slider (start mode) and custom style",
mode: "start",
class: "custom",
unit: "mm",
},
{
id: "slider-end-custom",
label: "Slider (end mode) and custom style",
mode: "end",
class: "custom",
unit: "mm",
},
{
id: "slider-cursor-custom",
label: "Slider (cursor mode) and custom style",
mode: "cursor",
class: "custom",
unit: "mm",
},
];

Expand Down Expand Up @@ -93,6 +97,7 @@ export class DemoHaBarSlider extends LitElement {
@value-changed=${this.handleValueChanged}
@slider-moved=${this.handleSliderMoved}
aria-labelledby=${id}
.tooltipUnit=${config.unit}
>
</ha-control-slider>
</div>
Expand All @@ -114,6 +119,7 @@ export class DemoHaBarSlider extends LitElement {
@value-changed=${this.handleValueChanged}
@slider-moved=${this.handleSliderMoved}
aria-label=${label}
.tooltipUnit=${config.unit}
>
</ha-control-slider>
`;
Expand Down
15 changes: 15 additions & 0 deletions src/common/translations/blank_before_unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FrontendLocaleData } from "../../data/translation";
import { blankBeforePercent } from "./blank_before_percent";

export const blankBeforeUnit = (
unit: string,
localeOptions?: FrontendLocaleData
): string => {
if (unit === "°") {
return "";
}
if (localeOptions && unit === "%") {
return blankBeforePercent(localeOptions);
}
return " ";
};
Loading

0 comments on commit bc21425

Please sign in to comment.