mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Put number selector label above the input (#21835)
This commit is contained in:
parent
362a6f46fe
commit
18210f35b5
@ -1,4 +1,11 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
import {
|
||||||
|
css,
|
||||||
|
CSSResultGroup,
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
nothing,
|
||||||
|
PropertyValues,
|
||||||
|
} from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
@ -60,12 +67,10 @@ export class HaNumberSelector extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
${this.label ? html`${this.label}${this.required ? "*" : ""}` : nothing}
|
||||||
<div class="input">
|
<div class="input">
|
||||||
${!isBox
|
${!isBox
|
||||||
? html`
|
? html`
|
||||||
${this.label
|
|
||||||
? html`${this.label}${this.required ? "*" : ""}`
|
|
||||||
: ""}
|
|
||||||
<ha-slider
|
<ha-slider
|
||||||
labeled
|
labeled
|
||||||
.min=${this.selector.number!.min}
|
.min=${this.selector.number!.min}
|
||||||
@ -75,10 +80,11 @@ export class HaNumberSelector extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
@change=${this._handleSliderChange}
|
@change=${this._handleSliderChange}
|
||||||
|
.ticks=${this.selector.number?.slider_ticks}
|
||||||
>
|
>
|
||||||
</ha-slider>
|
</ha-slider>
|
||||||
`
|
`
|
||||||
: ""}
|
: nothing}
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.inputMode=${this.selector.number?.step === "any" ||
|
.inputMode=${this.selector.number?.step === "any" ||
|
||||||
(this.selector.number?.step ?? 1) % 1 !== 0
|
(this.selector.number?.step ?? 1) % 1 !== 0
|
||||||
@ -105,7 +111,7 @@ export class HaNumberSelector extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
${!isBox && this.helper
|
${!isBox && this.helper
|
||||||
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
: ""}
|
: nothing}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +147,9 @@ export class HaNumberSelector extends LitElement {
|
|||||||
}
|
}
|
||||||
ha-slider {
|
ha-slider {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
margin-right: 16px;
|
||||||
|
margin-inline-end: 16px;
|
||||||
|
margin-inline-start: 0;
|
||||||
}
|
}
|
||||||
ha-textfield {
|
ha-textfield {
|
||||||
--ha-textfield-input-width: 40px;
|
--ha-textfield-input-width: 40px;
|
||||||
|
@ -20,6 +20,7 @@ export class HaSlider extends MdSlider {
|
|||||||
--md-sys-color-on-surface: var(--primary-text-color);
|
--md-sys-color-on-surface: var(--primary-text-color);
|
||||||
--md-slider-handle-width: 14px;
|
--md-slider-handle-width: 14px;
|
||||||
--md-slider-handle-height: 14px;
|
--md-slider-handle-height: 14px;
|
||||||
|
--md-slider-state-layer-size: 24px;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
min-inline-size: 100px;
|
min-inline-size: 100px;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
|
@ -323,6 +323,7 @@ export interface NumberSelector {
|
|||||||
step?: number | "any";
|
step?: number | "any";
|
||||||
mode?: "box" | "slider";
|
mode?: "box" | "slider";
|
||||||
unit_of_measurement?: string;
|
unit_of_measurement?: string;
|
||||||
|
slider_ticks?: boolean;
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ export class HuiDialogEditSection extends LitElement {
|
|||||||
number: {
|
number: {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: maxColumns,
|
max: maxColumns,
|
||||||
|
slider_ticks: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -77,6 +77,7 @@ export class HuiViewEditor extends LitElement {
|
|||||||
min: 1,
|
min: 1,
|
||||||
max: 10,
|
max: 10,
|
||||||
mode: "slider",
|
mode: "slider",
|
||||||
|
slider_ticks: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user