mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add badges support to sections view (#19929)
This commit is contained in:
parent
ca7e257e95
commit
67d8765624
@ -2,8 +2,4 @@ export const DEFAULT_VIEW_LAYOUT = "masonry";
|
||||
export const PANEL_VIEW_LAYOUT = "panel";
|
||||
export const SIDEBAR_VIEW_LAYOUT = "sidebar";
|
||||
export const SECTION_VIEW_LAYOUT = "sections";
|
||||
export const VIEWS_NO_BADGE_SUPPORT = [
|
||||
PANEL_VIEW_LAYOUT,
|
||||
SIDEBAR_VIEW_LAYOUT,
|
||||
SECTION_VIEW_LAYOUT,
|
||||
];
|
||||
export const VIEWS_NO_BADGE_SUPPORT = [PANEL_VIEW_LAYOUT, SIDEBAR_VIEW_LAYOUT];
|
||||
|
@ -291,12 +291,6 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.badges {
|
||||
margin: 8px 16px;
|
||||
font-size: 85%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#columns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
updateLovelaceContainer,
|
||||
} from "../editor/lovelace-path";
|
||||
import { HuiSection } from "../sections/hui-section";
|
||||
import type { Lovelace } from "../types";
|
||||
import type { Lovelace, LovelaceBadge } from "../types";
|
||||
|
||||
@customElement("hui-sections-view")
|
||||
export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
@ -34,6 +34,8 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
|
||||
@property({ attribute: false }) public sections: HuiSection[] = [];
|
||||
|
||||
@property({ attribute: false }) public badges: LovelaceBadge[] = [];
|
||||
|
||||
@state() private _config?: LovelaceViewConfig;
|
||||
|
||||
public setConfig(config: LovelaceViewConfig): void {
|
||||
@ -57,6 +59,9 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
const editMode = this.lovelace.editMode;
|
||||
|
||||
return html`
|
||||
${this.badges.length > 0
|
||||
? html`<div class="badges">${this.badges}</div>`
|
||||
: ""}
|
||||
<ha-sortable
|
||||
.disabled=${!editMode}
|
||||
@item-moved=${this._sectionMoved}
|
||||
@ -232,6 +237,12 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.badges {
|
||||
margin: 12px 8px 16px 8px;
|
||||
font-size: 85%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.section {
|
||||
position: relative;
|
||||
border-radius: var(--ha-card-border-radius, 12px);
|
||||
|
Loading…
x
Reference in New Issue
Block a user