diff --git a/src/app/components/building-passport/CurrentEfficiencyCard.tsx b/src/app/components/building-passport/CurrentEfficiencyCard.tsx index abcd2a69..723cb630 100644 --- a/src/app/components/building-passport/CurrentEfficiencyCard.tsx +++ b/src/app/components/building-passport/CurrentEfficiencyCard.tsx @@ -21,6 +21,27 @@ function getEpcHex(letter: string | null | undefined): string { } } +const EPC_STOPS = [ + { sap: 0, color: "#e41e3b" }, // G + { sap: 21, color: "#ef8026" }, // F + { sap: 39, color: "#f3a96a" }, // E + { sap: 55, color: "#f7cd14" }, // D + { sap: 69, color: "#8dbd40" }, // C + { sap: 81, color: "#2da55c" }, // B + { sap: 92, color: "#117d58" }, // A +]; + +function getEpcGradient(sapPoints: number, epcHex: string): string { + if (sapPoints <= 0) return epcHex; + const stops = EPC_STOPS.filter(s => s.sap <= sapPoints); + const gradientStops = stops.map(s => { + const pct = s.sap === 0 ? 0 : (s.sap / sapPoints) * 100; + return `${s.color} ${pct.toFixed(1)}%`; + }); + gradientStops.push(`${epcHex} 100%`); + return `linear-gradient(to right, ${gradientStops.join(", ")})`; +} + function getEpcDescription(letter: string | null | undefined): string { switch (letter?.toUpperCase()) { case "A": @@ -104,7 +125,7 @@ export function CurrentEfficiencyCard({ className="absolute inset-y-0 left-0 rounded-full" style={{ width: `${Math.min(100, Math.max(2, sapPoints))}%`, - background: "linear-gradient(to right, #e41e3b, #ef8026, #f7cd14, #8dbd40, #117d58)", + background: getEpcGradient(sapPoints, epcHex), }} /> diff --git a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx index b447181e..7ef022eb 100644 --- a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx +++ b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx @@ -200,7 +200,7 @@ const coreColumns: ColumnDef[] = [
{address}