Refactor column counts for area cards and sensors

- Area cards:
  Stacking the card per two, results into too small card when using
  HASS area cards.
  Cards are now stacked at a maximum of 1 HASS card or 2 of every other.

- Binary sensor cards:
  Since the parametertype of stackHorizontal has been changed, there's
  no need to provide a column count anymore. It defaults to 2.
This commit is contained in:
DigiLive
2025-05-02 12:05:23 +02:00
parent abd92912b2
commit 957a299605
2 changed files with 7 additions and 3 deletions

View File

@@ -152,7 +152,7 @@ class MushroomStrategy extends HTMLTemplateElement {
});
if (domain === 'binary_sensor') {
domainCards = Registry.stackHorizontal(domainCards, 2);
domainCards = Registry.stackHorizontal(domainCards);
}
return domainCards.length ? { type: 'vertical-stack', cards: [titleCard, ...domainCards] } : null;

View File

@@ -209,7 +209,7 @@ class HomeView extends AbstractView {
return {
type: 'vertical-stack',
cards: Registry.stackHorizontal(cardConfigurations, 8),
cards: Registry.stackHorizontal(cardConfigurations),
};
}
@@ -228,12 +228,16 @@ class HomeView extends AbstractView {
const cardConfigurations: (TemplateCardConfig | AreaCardConfig)[] = [];
let onlyDefaultCards = true;
for (const area of Registry.areas) {
const moduleName =
Registry.strategyOptions.areas[area.area_id]?.type ?? Registry.strategyOptions.areas['_']?.type ?? 'default';
let AreaCard;
onlyDefaultCards = onlyDefaultCards && moduleName === 'default';
try {
AreaCard = (await import(`../cards/${moduleName}`)).default;
} catch (e) {
@@ -254,7 +258,7 @@ class HomeView extends AbstractView {
title: (Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
? undefined
: localize('generic.areas'),
cards: Registry.stackHorizontal(cardConfigurations, 2),
cards: Registry.stackHorizontal(cardConfigurations, { area: 1, 'custom:mushroom-template-card': 2 }),
};
}
}