mirror of
https://github.com/home-assistant/frontend
synced 2024-10-05 22:05:30 +02:00
Add ha-label-badge to gallery (#10248)
This commit is contained in:
parent
56deb15bca
commit
9e7acacb06
122
gallery/src/demos/demo-ha-label-badge.ts
Normal file
122
gallery/src/demos/demo-ha-label-badge.ts
Normal file
@ -0,0 +1,122 @@
|
||||
import { html, css, LitElement, TemplateResult } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import "../../../src/components/ha-label-badge";
|
||||
import "../../../src/components/ha-card";
|
||||
|
||||
const colors = ["#03a9f4", "#ffa600", "#43a047"];
|
||||
|
||||
const badges: {
|
||||
label?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
}[] = [
|
||||
{
|
||||
label: "label",
|
||||
},
|
||||
{
|
||||
label: "label",
|
||||
description: "Description",
|
||||
},
|
||||
{
|
||||
description: "Description",
|
||||
},
|
||||
{
|
||||
label: "label",
|
||||
description: "Description",
|
||||
image: "/images/living_room.png",
|
||||
},
|
||||
{
|
||||
description: "Description",
|
||||
image: "/images/living_room.png",
|
||||
},
|
||||
{
|
||||
label: "label",
|
||||
image: "/images/living_room.png",
|
||||
},
|
||||
{
|
||||
image: "/images/living_room.png",
|
||||
},
|
||||
{
|
||||
label: "big label",
|
||||
},
|
||||
{
|
||||
label: "big label",
|
||||
description: "Description",
|
||||
},
|
||||
{
|
||||
label: "big label",
|
||||
description: "Description",
|
||||
image: "/images/living_room.png",
|
||||
},
|
||||
];
|
||||
|
||||
@customElement("demo-ha-label-badge")
|
||||
export class DemoHaLabelBadge extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
${badges.map(
|
||||
(badge) => html`
|
||||
<ha-label-badge
|
||||
style="--ha-label-badge-color: ${colors[
|
||||
Math.floor(Math.random() * colors.length)
|
||||
]}"
|
||||
.label=${badge.label}
|
||||
.description=${badge.description}
|
||||
.image=${badge.image}
|
||||
>
|
||||
</ha-label-badge>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
</ha-card>
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
${badges.map(
|
||||
(badge) => html`
|
||||
<div class="badge">
|
||||
<ha-label-badge
|
||||
style="--ha-label-badge-color: ${colors[
|
||||
Math.floor(Math.random() * colors.length)
|
||||
]}"
|
||||
.label=${badge.label}
|
||||
.description=${badge.description}
|
||||
.image=${badge.image}
|
||||
>
|
||||
</ha-label-badge>
|
||||
<pre>${JSON.stringify(badge, null, 2)}</pre>
|
||||
</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
|
||||
static get styles() {
|
||||
return css`
|
||||
ha-card {
|
||||
max-width: 600px;
|
||||
margin: 24px auto;
|
||||
}
|
||||
pre {
|
||||
margin-left: 16px;
|
||||
background-color: var(--markdown-code-background-color);
|
||||
padding: 8px;
|
||||
}
|
||||
.badge {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: 16px;
|
||||
align-items: center;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"demo-ha-label-badge": DemoHaLabelBadge;
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import {
|
||||
} from "lit";
|
||||
import { property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import "./ha-svg-icon";
|
||||
|
||||
class HaLabelBadge extends LitElement {
|
||||
@property() public label?: string;
|
||||
|
Loading…
Reference in New Issue
Block a user