mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 07:46:37 +00:00
Add inline-arrow option to ha-select & ha-language-picker (#22935)
* Add inline-arrow option to ha-select & use it in some language pickers * Update src/components/ha-language-picker.ts Co-authored-by: Bram Kragten <mail@bramkragten.nl> --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
811977b366
commit
6b0afe6ebb
@ -66,6 +66,7 @@ class HaLandingPage extends LandingPageBaseElement {
|
|||||||
.label=${""}
|
.label=${""}
|
||||||
nativeName
|
nativeName
|
||||||
@value-changed=${this._languageChanged}
|
@value-changed=${this._languageChanged}
|
||||||
|
inlineArrow
|
||||||
></ha-language-picker>
|
></ha-language-picker>
|
||||||
<a
|
<a
|
||||||
href="https://www.home-assistant.io/getting-started/onboarding/"
|
href="https://www.home-assistant.io/getting-started/onboarding/"
|
||||||
|
@ -204,6 +204,7 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
.label=${""}
|
.label=${""}
|
||||||
nativeName
|
nativeName
|
||||||
@value-changed=${this._languageChanged}
|
@value-changed=${this._languageChanged}
|
||||||
|
inlineArrow
|
||||||
></ha-language-picker>
|
></ha-language-picker>
|
||||||
<a
|
<a
|
||||||
href="https://www.home-assistant.io/docs/authentication/"
|
href="https://www.home-assistant.io/docs/authentication/"
|
||||||
|
@ -31,6 +31,8 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public noSort = false;
|
@property({ type: Boolean }) public noSort = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public inlineArrow = false;
|
||||||
|
|
||||||
@state() _defaultLanguages: string[] = [];
|
@state() _defaultLanguages: string[] = [];
|
||||||
|
|
||||||
@query("ha-select") private _select!: HaSelect;
|
@query("ha-select") private _select!: HaSelect;
|
||||||
@ -144,6 +146,7 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
@closed=${stopPropagation}
|
@closed=${stopPropagation}
|
||||||
fixedMenuPosition
|
fixedMenuPosition
|
||||||
naturalMenuWidth
|
naturalMenuWidth
|
||||||
|
.inlineArrow=${this.inlineArrow}
|
||||||
>
|
>
|
||||||
${languageOptions.length === 0
|
${languageOptions.length === 0
|
||||||
? html`<ha-list-item value=""
|
? html`<ha-list-item value=""
|
||||||
|
@ -14,6 +14,8 @@ export class HaSelect extends SelectBase {
|
|||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public clearable = false;
|
@property({ type: Boolean, reflect: true }) public clearable = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public inlineArrow = false;
|
||||||
|
|
||||||
protected override render() {
|
protected override render() {
|
||||||
return html`
|
return html`
|
||||||
${super.render()}
|
${super.render()}
|
||||||
@ -42,6 +44,31 @@ export class HaSelect extends SelectBase {
|
|||||||
window.addEventListener("translations-updated", this._translationsUpdated);
|
window.addEventListener("translations-updated", this._translationsUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async firstUpdated() {
|
||||||
|
super.firstUpdated();
|
||||||
|
|
||||||
|
if (this.inlineArrow) {
|
||||||
|
this.shadowRoot
|
||||||
|
?.querySelector(".mdc-select__selected-text-container")
|
||||||
|
?.classList.add("inline-arrow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected updated(changedProperties) {
|
||||||
|
super.updated(changedProperties);
|
||||||
|
|
||||||
|
if (changedProperties.has("inlineArrow")) {
|
||||||
|
const textContainerElement = this.shadowRoot?.querySelector(
|
||||||
|
".mdc-select__selected-text-container"
|
||||||
|
);
|
||||||
|
if (this.inlineArrow) {
|
||||||
|
textContainerElement?.classList.add("inline-arrow");
|
||||||
|
} else {
|
||||||
|
textContainerElement?.classList.remove("inline-arrow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
window.removeEventListener(
|
window.removeEventListener(
|
||||||
@ -114,6 +141,9 @@ export class HaSelect extends SelectBase {
|
|||||||
inset-inline-end: 28px;
|
inset-inline-end: 28px;
|
||||||
direction: var(--direction);
|
direction: var(--direction);
|
||||||
}
|
}
|
||||||
|
.inline-arrow {
|
||||||
|
flex-grow: 0;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
|||||||
.label=${""}
|
.label=${""}
|
||||||
nativeName
|
nativeName
|
||||||
@value-changed=${this._languageChanged}
|
@value-changed=${this._languageChanged}
|
||||||
|
inlineArrow
|
||||||
></ha-language-picker>
|
></ha-language-picker>
|
||||||
<a
|
<a
|
||||||
href="https://www.home-assistant.io/getting-started/onboarding/"
|
href="https://www.home-assistant.io/getting-started/onboarding/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user