Fix calendar card height (#27052)
parent
866b478dc0
commit
6823c647b6
|
@ -1,5 +1,6 @@
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { getColorByIndex } from "../../../common/color/colors";
|
import { getColorByIndex } from "../../../common/color/colors";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
|
@ -16,7 +17,11 @@ import type {
|
||||||
import "../../calendar/ha-full-calendar";
|
import "../../calendar/ha-full-calendar";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning";
|
||||||
import type { LovelaceCard, LovelaceCardEditor } from "../types";
|
import type {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceGridOptions,
|
||||||
|
} from "../types";
|
||||||
import type { CalendarCardConfig } from "./types";
|
import type { CalendarCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-calendar-card")
|
@customElement("hui-calendar-card")
|
||||||
|
@ -48,6 +53,8 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public layout?: string;
|
||||||
|
|
||||||
@state() private _events: CalendarEvent[] = [];
|
@state() private _events: CalendarEvent[] = [];
|
||||||
|
|
||||||
@state() private _config?: CalendarCardConfig;
|
@state() private _config?: CalendarCardConfig;
|
||||||
|
@ -88,7 +95,16 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return this._config?.header ? 1 : 0 + 11;
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getGridOptions(): LovelaceGridOptions {
|
||||||
|
return {
|
||||||
|
rows: 6,
|
||||||
|
columns: 12,
|
||||||
|
min_columns: 4,
|
||||||
|
min_rows: 4,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
|
@ -118,6 +134,10 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="header">${this._config.title}</div>
|
<div class="header">${this._config.title}</div>
|
||||||
<ha-full-calendar
|
<ha-full-calendar
|
||||||
|
class=${classMap({
|
||||||
|
"is-grid": this.layout === "grid",
|
||||||
|
"is-panel": this.layout === "panel",
|
||||||
|
})}
|
||||||
.narrow=${this._narrow}
|
.narrow=${this._narrow}
|
||||||
.events=${this._events}
|
.events=${this._events}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
@ -224,6 +244,11 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||||
ha-full-calendar {
|
ha-full-calendar {
|
||||||
--calendar-height: 400px;
|
--calendar-height: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ha-full-calendar.is-grid,
|
||||||
|
ha-full-calendar.is-panel {
|
||||||
|
height: calc(100% - 16px);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue