mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16:39 +00:00
parent
8abbc71e91
commit
b17ea09b8b
@ -8,7 +8,7 @@ import {
|
|||||||
customElement,
|
customElement,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import chipStyles from "@material/chips/dist/mdc.chips.min.css";
|
import chipStyles from "@material/chips/dist/mdc.chips.min.css";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
@ -33,22 +33,27 @@ export class HaChips extends LitElement {
|
|||||||
${this.items.map(
|
${this.items.map(
|
||||||
(item, idx) =>
|
(item, idx) =>
|
||||||
html`
|
html`
|
||||||
<button
|
<div class="mdc-chip" .index=${idx} @click=${this._handleClick}>
|
||||||
class="mdc-chip"
|
<div class="mdc-chip__ripple" .ripple="${ripple()}"></div>
|
||||||
.index=${idx}
|
<span role="gridcell">
|
||||||
@click=${this._handleClick}
|
<span
|
||||||
>
|
role="button"
|
||||||
<span class="mdc-chip__text">${item}</span>
|
tabindex="0"
|
||||||
</button>
|
class="mdc-chip__primary-action"
|
||||||
|
>
|
||||||
|
<span class="mdc-chip__text">${item}</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleClick(ev) {
|
private _handleClick(ev): void {
|
||||||
fireEvent(this, "chip-clicked", {
|
fireEvent(this, "chip-clicked", {
|
||||||
index: ev.target.closest("button").index,
|
index: ev.currentTarget.index,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { classMap } from "lit-html/directives/class-map";
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
import { html, customElement } from "lit-element";
|
import { html, customElement } from "lit-element";
|
||||||
import { ripple } from "@material/mwc-ripple/ripple-directive.js";
|
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||||
|
|
||||||
import "@material/mwc-fab";
|
import "@material/mwc-fab";
|
||||||
import { Constructor } from "../types";
|
import { Constructor } from "../types";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user