forked from DigiLive/mushroom-strategy
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:
@@ -152,7 +152,7 @@ class MushroomStrategy extends HTMLTemplateElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (domain === 'binary_sensor') {
|
if (domain === 'binary_sensor') {
|
||||||
domainCards = Registry.stackHorizontal(domainCards, 2);
|
domainCards = Registry.stackHorizontal(domainCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
return domainCards.length ? { type: 'vertical-stack', cards: [titleCard, ...domainCards] } : null;
|
return domainCards.length ? { type: 'vertical-stack', cards: [titleCard, ...domainCards] } : null;
|
||||||
|
@@ -209,7 +209,7 @@ class HomeView extends AbstractView {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'vertical-stack',
|
type: 'vertical-stack',
|
||||||
cards: Registry.stackHorizontal(cardConfigurations, 8),
|
cards: Registry.stackHorizontal(cardConfigurations),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,12 +228,16 @@ class HomeView extends AbstractView {
|
|||||||
|
|
||||||
const cardConfigurations: (TemplateCardConfig | AreaCardConfig)[] = [];
|
const cardConfigurations: (TemplateCardConfig | AreaCardConfig)[] = [];
|
||||||
|
|
||||||
|
let onlyDefaultCards = true;
|
||||||
|
|
||||||
for (const area of Registry.areas) {
|
for (const area of Registry.areas) {
|
||||||
const moduleName =
|
const moduleName =
|
||||||
Registry.strategyOptions.areas[area.area_id]?.type ?? Registry.strategyOptions.areas['_']?.type ?? 'default';
|
Registry.strategyOptions.areas[area.area_id]?.type ?? Registry.strategyOptions.areas['_']?.type ?? 'default';
|
||||||
|
|
||||||
let AreaCard;
|
let AreaCard;
|
||||||
|
|
||||||
|
onlyDefaultCards = onlyDefaultCards && moduleName === 'default';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AreaCard = (await import(`../cards/${moduleName}`)).default;
|
AreaCard = (await import(`../cards/${moduleName}`)).default;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -254,7 +258,7 @@ class HomeView extends AbstractView {
|
|||||||
title: (Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
|
title: (Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
|
||||||
? undefined
|
? undefined
|
||||||
: localize('generic.areas'),
|
: localize('generic.areas'),
|
||||||
cards: Registry.stackHorizontal(cardConfigurations, 2),
|
cards: Registry.stackHorizontal(cardConfigurations, { area: 1, 'custom:mushroom-template-card': 2 }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user