1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 08:33:31 +01:00

Ensure energy cards appear at end of card picker

Add a new `sortAtEnd` option which will cause cards with this sort parameter to sink to the bottom of the card picker.
This commit is contained in:
Tom Carpenter
2026-02-24 12:14:27 +00:00
parent ffbfa55eaf
commit 28834aaa55
3 changed files with 23 additions and 0 deletions

View File

@@ -282,6 +282,12 @@ export class HuiCardPicker extends LitElement {
if (!a.isSuggested && b.isSuggested) {
return 1;
}
if (!a.sortAtEnd && b.sortAtEnd) {
return -1;
}
if (a.sortAtEnd && !b.sortAtEnd) {
return 1;
}
return stringCompare(
a.name || a.type,
b.name || b.type,

View File

@@ -48,66 +48,82 @@ export const coreCards: Card[] = [
{
type: "energy-date-selection",
showElement: true,
sortAtEnd: true,
},
{
type: "energy-distribution",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-usage-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-solar-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-gas-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-water-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "power-sources-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-devices-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-devices-detail-graph",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-sankey",
showElement: false,
sortAtEnd: true,
},
{
type: "power-sankey",
showElement: false,
sortAtEnd: true,
},
{
type: "water-sankey",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-solar-consumed-gauge",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-self-sufficiency-gauge",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-grid-neutrality-gauge",
showElement: false,
sortAtEnd: true,
},
{
type: "energy-carbon-consumed-gauge",
showElement: false,
sortAtEnd: true,
},
{
type: "statistic",

View File

@@ -67,6 +67,7 @@ export interface Card {
name?: string;
description?: string;
showElement?: boolean;
sortAtEnd?: boolean;
isCustom?: boolean;
isSuggested?: boolean;
}