mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Pass narrow to masonry view to calc columns (#7454)
This commit is contained in:
parent
6aff35196d
commit
9fbc94e8d8
@ -89,6 +89,7 @@ export interface LovelaceViewConfig {
|
|||||||
export interface LovelaceViewElement extends HTMLElement {
|
export interface LovelaceViewElement extends HTMLElement {
|
||||||
hass?: HomeAssistant;
|
hass?: HomeAssistant;
|
||||||
lovelace?: Lovelace;
|
lovelace?: Lovelace;
|
||||||
|
narrow?: boolean;
|
||||||
index?: number;
|
index?: number;
|
||||||
cards?: Array<LovelaceCard | HuiErrorCard>;
|
cards?: Array<LovelaceCard | HuiErrorCard>;
|
||||||
badges?: LovelaceBadge[];
|
badges?: LovelaceBadge[];
|
||||||
|
@ -490,6 +490,10 @@ class HUIRoot extends LitElement {
|
|||||||
huiView.hass = this.hass;
|
huiView.hass = this.hass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("narrow") && huiView) {
|
||||||
|
huiView.narrow = this.narrow;
|
||||||
|
}
|
||||||
|
|
||||||
let newSelectView;
|
let newSelectView;
|
||||||
let force = false;
|
let force = false;
|
||||||
|
|
||||||
@ -753,6 +757,7 @@ class HUIRoot extends LitElement {
|
|||||||
|
|
||||||
view.lovelace = this.lovelace;
|
view.lovelace = this.lovelace;
|
||||||
view.hass = this.hass;
|
view.hass = this.hass;
|
||||||
|
view.narrow = this.narrow;
|
||||||
|
|
||||||
const configBackground = viewConfig.background || this.config.background;
|
const configBackground = viewConfig.background || this.config.background;
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public lovelace?: Lovelace;
|
@property({ attribute: false }) public lovelace?: Lovelace;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
@property({ type: Number }) public index?: number;
|
@property({ type: Number }) public index?: number;
|
||||||
|
|
||||||
@property({ attribute: false }) public cards: Array<
|
@property({ attribute: false }) public cards: Array<
|
||||||
@ -128,6 +130,10 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("narrow")) {
|
||||||
|
this._updateColumns();
|
||||||
|
}
|
||||||
|
|
||||||
const oldLovelace = changedProperties.get("lovelace") as
|
const oldLovelace = changedProperties.get("lovelace") as
|
||||||
| Lovelace
|
| Lovelace
|
||||||
| undefined;
|
| undefined;
|
||||||
@ -252,7 +258,8 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
|
|||||||
// Do -1 column if the menu is docked and open
|
// Do -1 column if the menu is docked and open
|
||||||
this._columns = Math.max(
|
this._columns = Math.max(
|
||||||
1,
|
1,
|
||||||
matchColumns - Number(this.hass!.dockedSidebar === "docked")
|
matchColumns -
|
||||||
|
Number(!this.narrow && this.hass!.dockedSidebar === "docked")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ export class HUIView extends UpdatingElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public lovelace?: Lovelace;
|
@property({ attribute: false }) public lovelace?: Lovelace;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
@property({ type: Number }) public index?: number;
|
@property({ type: Number }) public index?: number;
|
||||||
|
|
||||||
@internalProperty() private _cards: Array<LovelaceCard | HuiErrorCard> = [];
|
@internalProperty() private _cards: Array<LovelaceCard | HuiErrorCard> = [];
|
||||||
@ -111,6 +113,7 @@ export class HUIView extends UpdatingElement {
|
|||||||
this._createCards(viewConfig!);
|
this._createCards(viewConfig!);
|
||||||
|
|
||||||
this._layoutElement!.hass = this.hass;
|
this._layoutElement!.hass = this.hass;
|
||||||
|
this._layoutElement!.narrow = this.narrow;
|
||||||
this._layoutElement!.lovelace = lovelace;
|
this._layoutElement!.lovelace = lovelace;
|
||||||
this._layoutElement!.index = this.index;
|
this._layoutElement!.index = this.index;
|
||||||
}
|
}
|
||||||
@ -127,6 +130,10 @@ export class HUIView extends UpdatingElement {
|
|||||||
this._layoutElement!.hass = this.hass;
|
this._layoutElement!.hass = this.hass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has("narrow")) {
|
||||||
|
this._layoutElement!.narrow = this.narrow;
|
||||||
|
}
|
||||||
|
|
||||||
if (editModeChanged) {
|
if (editModeChanged) {
|
||||||
this._layoutElement!.lovelace = lovelace;
|
this._layoutElement!.lovelace = lovelace;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user