mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Put boolean selector helper inside field (#21831)
This commit is contained in:
parent
6d84523456
commit
1c9d411d3a
@ -18,9 +18,9 @@ export class HaFormfield extends FormfieldBase {
|
|||||||
|
|
||||||
return html` <div class="mdc-form-field ${classMap(classes)}">
|
return html` <div class="mdc-form-field ${classMap(classes)}">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<label class="mdc-label" @click=${this._labelClick}
|
<label class="mdc-label" @click=${this._labelClick}>
|
||||||
><slot name="label">${this.label}</slot></label
|
<slot name="label">${this.label}</slot>
|
||||||
>
|
</label>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,13 +57,13 @@ export class HaFormfield extends FormfieldBase {
|
|||||||
}
|
}
|
||||||
.mdc-form-field {
|
.mdc-form-field {
|
||||||
align-items: var(--ha-formfield-align-items, center);
|
align-items: var(--ha-formfield-align-items, center);
|
||||||
|
gap: 4px;
|
||||||
}
|
}
|
||||||
.mdc-form-field > label {
|
.mdc-form-field > label {
|
||||||
direction: var(--direction);
|
direction: var(--direction);
|
||||||
margin-inline-start: 0;
|
margin-inline-start: 0;
|
||||||
margin-inline-end: auto;
|
margin-inline-end: auto;
|
||||||
padding-inline-start: 4px;
|
padding: 0;
|
||||||
padding-inline-end: 0;
|
|
||||||
}
|
}
|
||||||
:host([disabled]) label {
|
:host([disabled]) label {
|
||||||
color: var(--disabled-text-color);
|
color: var(--disabled-text-color);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
@ -28,10 +28,13 @@ export class HaBooleanSelector extends LitElement {
|
|||||||
@change=${this._handleChange}
|
@change=${this._handleChange}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
></ha-switch>
|
></ha-switch>
|
||||||
|
<span slot="label">
|
||||||
|
<p class="primary">${this.label}</p>
|
||||||
|
${this.helper
|
||||||
|
? html`<p class="secondary">${this.helper}</p>`
|
||||||
|
: nothing}
|
||||||
|
</span>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
${this.helper
|
|
||||||
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
|
||||||
: ""}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,10 +50,21 @@ export class HaBooleanSelector extends LitElement {
|
|||||||
return css`
|
return css`
|
||||||
ha-formfield {
|
ha-formfield {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 56px;
|
min-height: 56px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
--mdc-typography-body2-font-size: 1em;
|
--mdc-typography-body2-font-size: 1em;
|
||||||
}
|
}
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.secondary {
|
||||||
|
direction: var(--direction);
|
||||||
|
padding-top: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: var(--mdc-typography-body2-font-weight, 400);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user