Skip to content

Commit

Permalink
Use ha-checkbox instead of hacs-checkbox (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Nov 6, 2021
1 parent b146840 commit 53690fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 101 deletions.
2 changes: 2 additions & 0 deletions src/components/dialogs/hacs-add-repository-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {
>
<div class="searchandfilter">
<search-input
.hass=${this.hass}
no-label-float
.label=${this.hacs.localize("search.placeholder")}
.filter=${this._searchInput || ""}
Expand Down Expand Up @@ -347,6 +348,7 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {
hacs-filter {
width: 100%;
margin-left: -32px;
}
div[secondary] {
width: 88%;
Expand Down
89 changes: 0 additions & 89 deletions src/components/hacs-checkbox.ts

This file was deleted.

27 changes: 15 additions & 12 deletions src/components/hacs-filter.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
import "../../homeassistant-frontend/src/components/ha-checkbox";
import "../../homeassistant-frontend/src/components/ha-formfield";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { Filter } from "../data/common";
import { Hacs } from "../data/hacs";
import { HacsStyles } from "../styles/hacs-common-style";
import "./hacs-checkbox";

@customElement("hacs-filter")
export class HacsFilter extends LitElement {
@property({ attribute: false }) public filters: Filter[];
@property({ attribute: false }) public hacs: Hacs;
@property({ attribute: false }) public filters?: Filter[];

protected async firstUpdated() {
this.addEventListener("checkbox-change", (e) => this._filterClick(e));
}
@property({ attribute: false }) public hacs!: Hacs;

protected render(): TemplateResult | void {
return html`
<div class="filter">
${this.filters?.map(
(filter) => html`
<hacs-checkbox
<ha-formfield
class="checkbox"
.label=${this.hacs.localize(`common.${filter.id}`) || filter.value}
.id=${filter.id}
.checked=${filter.checked || false}
/>
</hacs-checkbox>`
>
<ha-checkbox
.checked=${filter.checked || false}
.id=${filter.id}
@click=${this._filterClick}
>
</ha-checkbox>
</ha-formfield>
`
)}
</div>
`;
}

private _filterClick(ev): void {
const filter = ev.detail;
const filter = ev.currentTarget;
this.dispatchEvent(
new CustomEvent("filter-change", {
detail: {
Expand Down
2 changes: 2 additions & 0 deletions src/panels/hacs-store-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class HacsStorePanel extends LitElement {
<div slot="header">
<slot name="header">
<search-input
.hass=${this.hass}
class="header"
no-label-float
.label=${this.hacs.localize("search.installed")}
Expand All @@ -194,6 +195,7 @@ export class HacsStorePanel extends LitElement {
`
: html`<div class="search">
<search-input
.hass=${this.hass}
no-label-float
.label=${newRepositories.length === 0
? this.hacs.localize("search.installed")
Expand Down

0 comments on commit 53690fc

Please sign in to comment.