Skip to content

Commit da2d09c

Browse files
squizzer73claude
andcommitted
v0.2.7 — card height matches content, no empty space
Remove height:100% from :host and ha-card, and flex:1 from grid-wrapper. Card now auto-sizes to its content so trimmed grids with few rooms don't leave large empty areas. Canvas fills wrapper width via ResizeObserver; aspect-ratio CSS drives the height. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent acc4227 commit da2d09c

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.2.7] — 2026-05-13
4+
5+
### Fixed
6+
- **Card height now matches content** — removed `height: 100%` from the card so it shrinks to fit its rooms rather than expanding to fill the full dashboard tile. This eliminates the large empty space that appeared above/below trimmed grids with few rooms. Cards in the dashboard will now be as tall as their content naturally requires.
7+
8+
---
9+
310
## [0.2.6] — 2026-05-13
411

512
### Fixed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lovelace-house-card",
33
"type": "module",
4-
"version": "0.2.6",
4+
"version": "0.2.7",
55
"description": "Visual house floorplan card for Home Assistant",
66
"main": "dist/house-card.js",
77
"scripts": {

src/house-card.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ class HouseCard extends LitElement {
4848
return css`
4949
:host {
5050
display: block;
51-
height: 100%;
5251
font-family: var(--primary-font-family, sans-serif);
5352
}
5453
5554
ha-card {
5655
overflow: hidden;
5756
padding: 0;
58-
height: 100%;
5957
display: flex;
6058
flex-direction: column;
6159
}
@@ -124,13 +122,11 @@ class HouseCard extends LitElement {
124122
125123
.grid-wrapper {
126124
box-sizing: border-box;
127-
flex: 1;
128125
display: flex;
129126
flex-direction: column;
130127
align-items: center;
131128
justify-content: center;
132129
padding: 10px 14px 22px;
133-
min-height: 0;
134130
overflow: hidden;
135131
perspective: 2400px;
136132
perspective-origin: 50% 50%;
@@ -522,20 +518,11 @@ class HouseCard extends LitElement {
522518
const wrapper = this.shadowRoot?.querySelector('.grid-wrapper');
523519
const canvas = this.shadowRoot?.querySelector('.grid-canvas');
524520
if (!wrapper || !canvas) return;
525-
const floors = this._config?.floors;
526-
const floor = floors?.[this._activeFloor] ?? floors?.[0];
527-
if (!floor?.cols || !floor?.rows) return;
528521
const wW = wrapper.clientWidth;
529-
const wH = wrapper.clientHeight;
530-
if (!wW || !wH) return;
531-
// Use trimmed bounding box for sizing so empty rows/cols don't waste space
532-
const { usedCols, usedRows } = this._floorBounds(floor);
533-
// Visual height after rotateX(38deg) = DOM_height × cos(38°)
534-
// DOM_height = canvas_width × usedRows/usedCols
535-
// Constrain so visual height ≤ wrapper height:
536-
const cos38 = Math.cos(38 * Math.PI / 180); // ≈ 0.788
537-
const maxW = Math.floor(Math.min(wW, wH * usedCols / (usedRows * cos38)));
538-
canvas.style.width = maxW + 'px';
522+
if (!wW) return;
523+
// Card now auto-sizes to content, so just fill the wrapper width.
524+
// The aspect-ratio CSS property handles the height automatically.
525+
canvas.style.width = wW + 'px';
539526
}
540527

541528
setConfig(config) {

0 commit comments

Comments
 (0)