From c2eba1bfffe80923bba5ca5a2c481dc567d38fdb Mon Sep 17 00:00:00 2001 From: default Date: Wed, 19 Nov 2025 10:31:17 +0000 Subject: [PATCH] fix(dashboard): fix temperature gauge positioning when low temp is 0 --- apps/dashboard/src/App.tsx | 6 +++++- bun.lock | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/App.tsx b/apps/dashboard/src/App.tsx index 9acfa44..5d0011d 100644 --- a/apps/dashboard/src/App.tsx +++ b/apps/dashboard/src/App.tsx @@ -251,7 +251,11 @@ function WeatherTile() { const temperature = Math.round(currentWeather.temperature) const lowTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMin ?? 0) const highTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMax ?? 0) - const percentage = lowTemp && highTemp ? (temperature - lowTemp) / (highTemp - lowTemp) : 0 + // Calculate percentage: handle case where lowTemp might be 0 (falsy) by checking for valid numbers + const tempRange = highTemp - lowTemp + const percentage = tempRange !== 0 && !Number.isNaN(tempRange) + ? Math.max(0, Math.min(1, (temperature - lowTemp) / tempRange)) + : 0 const highlightIndexStart = Math.floor((1 - percentage) * 23) const WeatherIcon = getWeatherIcon(currentWeather.conditionCode) diff --git a/bun.lock b/bun.lock index e35286f..b634f1b 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "monorepo",