Fix grid card size when square (#9056)

This commit is contained in:
Paulus Schoutsen 2021-04-30 09:57:20 -07:00 committed by GitHub
parent d57e8a45d3
commit 92b32458ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -143,6 +143,15 @@ const CONFIGS = [
entity: light.kitchen_lights
`,
},
{
heading: "Size for single card",
config: `
- type: grid
cards:
- type: entity
entity: light.kitchen_lights
`,
},
{
heading: "Vertical Stack",

View File

@ -25,7 +25,9 @@ class HuiGridCard extends HuiStackCard<GridCardConfig> {
if (this.square) {
const rowHeight = SQUARE_ROW_HEIGHTS_BY_COLUMNS[this.columns] || 1;
return (
(this._cards.length / this.columns) * rowHeight +
(this._cards.length < this.columns
? rowHeight
: (this._cards.length / this.columns) * rowHeight) +
(this._config.title ? 1 : 0)
);
}