Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion code/ali-je-vroce/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ export const opisi = {
'p80': 'Res je vroče!',
'p95': 'Peklensko vroče je!',
'': '',
} satisfies PercentileDescriptions
} satisfies PercentileDescriptions

/**
* Alternative descriptions used when the measured average temperature is below 30 C.
*/
export const opisi_pod_30 = {
'p00': 'Izjemno hladno za ta čas leta',
'p05': 'Zelo hladno za ta čas leta',
'p20': 'Hladneje kot običajno',
'p40': 'Običajne temperature za ta čas leta',
'p60': 'Topleje kot običajno',
'p80': 'Zelo toplo za ta čas leta',
'p95': 'Izjemno toplo za ta čas leta',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nerad popravljam tekst, ampak meni se lepse slisi "za ta letni čas".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Letni časi" so samo štirje in bi se lahko zdelo, da gre za bolj grobo oceno, kot je v resnici - na osnovi dolgoletnih povprečij.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potem pa mogoce "čas v letu"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meni je ta čas v letu tudi ok. Verjetno je ta čas leta nepravilno jezikovno.

'': '',
} satisfies PercentileDescriptions
14 changes: 11 additions & 3 deletions code/ali-je-vroce/vroce.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { onMount, Show } from "solid-js";
import { vrednosti, opisi, percentile_labels } from "./constants.ts";
import { createMemo, onMount, Show } from "solid-js";
import { vrednosti, opisi, opisi_pod_30, percentile_labels } from "./constants.ts";

// Import custom hooks
import { useWeatherData } from "./hooks/useWeatherData.ts";
Expand Down Expand Up @@ -70,6 +70,14 @@ export function AliJeVroce() {
initialize();
});

const getDescriptionsForTemperature = createMemo(() => {
const avg = tempAvg();
if (avg != null && Number.isFinite(+avg) && +avg < 30) {
return opisi_pod_30;
}
return opisi;
});

return (
<div class="text-center">
<h1 class="not-prose font-normal text-5xl font-sans text-balance">
Expand All @@ -96,7 +104,7 @@ export function AliJeVroce() {
isStale={false}
labels={percentile_labels}
values={vrednosti}
descriptions={opisi}
descriptions={getDescriptionsForTemperature()}
/>

<ErrorMessage error={dataError() || ""} onRetry={retryLoadingData} />
Expand Down