mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add ha-chip to gallery (#10252)
This commit is contained in:
parent
4a00957b71
commit
a3d4969d7b
61
gallery/src/demos/demo-ha-chip.ts
Normal file
61
gallery/src/demos/demo-ha-chip.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { mdiHomeAssistant } from "@mdi/js";
|
||||||
|
import { css, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
|
import "../../../src/components/ha-chip";
|
||||||
|
import "../../../src/components/ha-svg-icon";
|
||||||
|
|
||||||
|
const chips: {
|
||||||
|
icon?: string;
|
||||||
|
content?: string;
|
||||||
|
}[] = [
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
icon: mdiHomeAssistant,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: "Content",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: mdiHomeAssistant,
|
||||||
|
content: "Content",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
@customElement("demo-ha-chip")
|
||||||
|
export class DemoHaChip extends LitElement {
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<ha-card header="ha-chip demo">
|
||||||
|
<div class="card-content">
|
||||||
|
${chips.map(
|
||||||
|
(chip) => html`
|
||||||
|
<ha-chip .hasIcon=${chip.icon !== undefined}>
|
||||||
|
${chip.icon
|
||||||
|
? html`<ha-svg-icon slot="icon" .path=${chip.icon}>
|
||||||
|
</ha-svg-icon>`
|
||||||
|
: ""}
|
||||||
|
${chip.content}
|
||||||
|
</ha-chip>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ha-card>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return css`
|
||||||
|
ha-card {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 24px auto;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"demo-ha-chip": DemoHaChip;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user