From 298c8ef597b3fa1ecd0eaeb88682754e5c9c66b1 Mon Sep 17 00:00:00 2001 From: terraputix Date: Fri, 9 Jan 2026 21:18:19 +0100 Subject: [PATCH] wip improvements but still problematic --- components.json | 2 +- cspell.json | 5 + package-lock.json | 1 + package.json | 1 + .../ui/alert/alert-description.svelte | 2 +- .../components/ui/alert/alert-title.svelte | 2 +- src/lib/components/ui/alert/alert.svelte | 2 +- src/lib/components/ui/button/button.svelte | 2 +- .../components/ui/checkbox/checkbox.svelte | 2 +- .../ui/dialog/dialog-content.svelte | 2 +- .../ui/dialog/dialog-description.svelte | 2 +- .../components/ui/dialog/dialog-footer.svelte | 2 +- .../components/ui/dialog/dialog-header.svelte | 2 +- .../ui/dialog/dialog-overlay.svelte | 2 +- .../components/ui/dialog/dialog-title.svelte | 2 +- src/lib/components/ui/input/input.svelte | 2 +- src/lib/components/ui/label/label.svelte | 2 +- .../ui/select/select-content.svelte | 4 +- .../ui/select/select-group-heading.svelte | 2 +- .../components/ui/select/select-item.svelte | 2 +- .../components/ui/select/select-label.svelte | 2 +- .../select/select-scroll-down-button.svelte | 2 +- .../ui/select/select-scroll-up-button.svelte | 2 +- .../ui/select/select-separator.svelte | 2 +- .../ui/select/select-trigger.svelte | 2 +- .../components/ui/separator/separator.svelte | 2 +- src/lib/components/ui/switch/switch.svelte | 2 +- src/lib/stores/url-hash-store.ts | 143 +++- src/lib/utils/index.ts | 23 + src/lib/{utils.ts => utils/ui.ts} | 7 - src/routes/weather/+layout.svelte | 55 -- src/routes/weather/canvas/cloud-cover.ts | 11 +- src/routes/weather/canvas/daylight.ts | 2 + src/routes/weather/canvas/precip.ts | 9 +- src/routes/weather/canvas/raster.ts | 3 +- src/routes/weather/canvas/temp-gradient.ts | 9 +- src/routes/weather/config.d.ts | 8 - src/routes/weather/config.ts | 13 + src/routes/weather/utils/colors.ts | 40 +- src/routes/weather/utils/weather-codes.ts | 3 +- .../weather/week/[location]/+page.svelte | 612 +++++++++--------- 41 files changed, 572 insertions(+), 423 deletions(-) create mode 100644 cspell.json create mode 100644 src/lib/utils/index.ts rename src/lib/{utils.ts => utils/ui.ts} (82%) delete mode 100644 src/routes/weather/config.d.ts create mode 100644 src/routes/weather/config.ts diff --git a/components.json b/components.json index c8f04c6..c6f9bd1 100644 --- a/components.json +++ b/components.json @@ -6,7 +6,7 @@ }, "aliases": { "components": "$lib/components", - "utils": "$lib/utils", + "utils": "$lib/utils/ui", "ui": "$lib/components/ui", "hooks": "$lib/hooks", "lib": "$lib" diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..10a385b --- /dev/null +++ b/cspell.json @@ -0,0 +1,5 @@ +{ + "userWords": [ + "ConfigInterface" + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 64531c5..fc375fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "open-meteo-weather", "version": "0.0.1", "dependencies": { + "@openmeteo/sdk": "^1.23.0", "highcharts": "^12.4.0", "mode-watcher": "^1.1.0", "openmeteo": "^1.2.3" diff --git a/package.json b/package.json index cc36e3b..d6e0dfb 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "vitest-browser-svelte": "^2.0.1" }, "dependencies": { + "@openmeteo/sdk": "^1.23.0", "highcharts": "^12.4.0", "mode-watcher": "^1.1.0", "openmeteo": "^1.2.3" diff --git a/src/lib/components/ui/alert/alert-description.svelte b/src/lib/components/ui/alert/alert-description.svelte index ceccee5..cc805d7 100644 --- a/src/lib/components/ui/alert/alert-description.svelte +++ b/src/lib/components/ui/alert/alert-description.svelte @@ -1,6 +1,6 @@ @@ -304,10 +358,10 @@ style="min-height: 256px" class="weather-week gap-md-2 mb-4 flex flex-col md:flex-row" > - {#await weatherDaily then wd} - {#each wd.daily.time as time, index (index)} + {#if weatherDaily} + {#each weatherDaily.time as time, index (index)} {@const selected = time.getDate() === selectedDay.getDate()} - {#if !isNaN(wd.daily.temperature_2m_max.values(index).toFixed(1))} + {#if !isNaN(weatherDaily.temperature_2m_max.values(index)!)} {/if} {/each} - {:catch error} -

{error.message}

- {/await} + {:else} +

Loading...

+ {/if}

@@ -410,7 +464,7 @@
Weather Week {location.name} - {#await weather then weather} + {#if weather && weather.entries[0] && weather.entries[0].values} + {@const tempVal = weather.entries[0].values?.[index] ?? '0'} @@ -475,7 +529,7 @@ xlink:href="/images/weather-icons/wi-{weather.hourlyTime[index].getHours() > 6 && weather.hourlyTime[index].getHours() < 21 ? 'day' - : 'night'}-{weatherCodes[weatherCodesHourly[index]]}.svg#Layer_1" + : 'night'}-{weatherCodes[weatherCodesHourly?.[index] ?? 0]}.svg#Layer_1" > @@ -490,7 +544,7 @@ >Temp graph {#each weather.indexes as index, j (j)} - {@const temp = weather.entries[0].values[index]} + {@const temp = Number(weather.entries[0].values?.[index])} {#if !isNaN(temp)} {#each weather.indexes as index, j (j)} - {#if !isNaN(entry.values[index])} + {@const val = entry.values?.[index]} + {@const valNum = Number(val)} + {@const bgColor = getColor(valNum, $params.temperature_unit)} + {#if val !== undefined && !isNaN(valNum)} + {entry.name === 'precipitation' || entry.name === 'temperature_2m' - ? entry.values[index].toFixed(1) - : entry.values[index]}{val} {/if} {/each} @@ -577,7 +611,7 @@ >Wind Dir. {#each weather.indexes as index, j (j)} - {#if !isNaN(weather.windDirections[index])} + {#if weather.windDirections && !isNaN(weather.windDirections[index])}
@@ -616,7 +650,7 @@ Sunset: {pad(sunset.getHours())}:{pad(sunset.getMinutes())}
- {/await} + {/if}