Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline-arrow option to ha-select & ha-language-picker #22935

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions landing-page/src/ha-landing-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class HaLandingPage extends LandingPageBaseElement {
.label=${""}
nativeName
@value-changed=${this._languageChanged}
inlineArrow
></ha-language-picker>
<a
href="https://www.home-assistant.io/getting-started/onboarding/"
Expand Down
1 change: 1 addition & 0 deletions src/auth/ha-authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
.label=${""}
nativeName
@value-changed=${this._languageChanged}
inlineArrow
></ha-language-picker>
<a
href="https://www.home-assistant.io/docs/authentication/"
Expand Down
3 changes: 3 additions & 0 deletions src/components/ha-language-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class HaLanguagePicker extends LitElement {

@property({ type: Boolean }) public noSort = false;

@property({ type: Boolean }) public inlineArrow = false;

@state() _defaultLanguages: string[] = [];

@query("ha-select") private _select!: HaSelect;
Expand Down Expand Up @@ -144,6 +146,7 @@ export class HaLanguagePicker extends LitElement {
@closed=${stopPropagation}
fixedMenuPosition
naturalMenuWidth
.inlineArrow=${this.inlineArrow}
>
${languageOptions.length === 0
? html`<ha-list-item value=""
Expand Down
30 changes: 30 additions & 0 deletions src/components/ha-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class HaSelect extends SelectBase {

@property({ type: Boolean, reflect: true }) public clearable = false;

@property({ type: Boolean }) public inlineArrow = false;

protected override render() {
return html`
${super.render()}
Expand Down Expand Up @@ -42,6 +44,31 @@ export class HaSelect extends SelectBase {
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() {
super.disconnectedCallback();
window.removeEventListener(
Expand Down Expand Up @@ -114,6 +141,9 @@ export class HaSelect extends SelectBase {
inset-inline-end: 28px;
direction: var(--direction);
}
.inline-arrow {
flex-grow: 0;
}
`,
];
}
Expand Down
1 change: 1 addition & 0 deletions src/onboarding/ha-onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
.label=${""}
nativeName
@value-changed=${this._languageChanged}
inlineArrow
></ha-language-picker>
<a
href="https://www.home-assistant.io/getting-started/onboarding/"
Expand Down
Loading