+
+
+
{panel.title}
{panel.titleShort}
@@ -327,6 +328,8 @@
unit={panel.def.unit}
unitRight={panel.def.unitRight}
yMin={panel.def.yMin}
+ yPadTop={panel.def.yPadTop}
+ yPadBottom={panel.def.yPadBottom}
zeroBaseLeft={panel.def.zeroBaseLeft}
yMinRight={panel.def.yMinRight}
yMaxRight={panel.def.yMaxRight}
diff --git a/src/routes/weather/week/[location]/significance.ts b/src/routes/weather/week/[location]/significance.ts
index 663ad82..87989b0 100644
--- a/src/routes/weather/week/[location]/significance.ts
+++ b/src/routes/weather/week/[location]/significance.ts
@@ -13,6 +13,25 @@ export function precipIsSignificant(sum: number | null, unit: string): boolean {
return (sum ?? 0) >= min;
}
+/** Sunshine as a share of daylight, for the sun progress bar (0-100). */
+export function getSunshinePercent(
+ sunshineSeconds: number | null,
+ daylightSeconds: number
+): number {
+ if (!sunshineSeconds || daylightSeconds <= 0) return 0;
+ return Math.min(100, (sunshineSeconds / daylightSeconds) * 100);
+}
+
+/** Sun icon / bar colour by sunshine ratio: grey → pale gold → amber. */
+export function getSunshineColor(sunshineSeconds: number | null, daylightSeconds: number): string {
+ if (daylightSeconds <= 0) return '#d1d5db';
+ const ratio = (sunshineSeconds ?? 0) / daylightSeconds;
+ if (ratio >= 0.7) return '#f59e0b';
+ if (ratio >= 0.45) return '#fbbf24';
+ if (ratio >= 0.1) return '#fcd34d';
+ return '#d1d5db';
+}
+
export function windIsSignificant(
speed: number | null,
gust: number | null,
diff --git a/src/routes/weather/week/[location]/variables.ts b/src/routes/weather/week/[location]/variables.ts
index df53a1c..7a31216 100644
--- a/src/routes/weather/week/[location]/variables.ts
+++ b/src/routes/weather/week/[location]/variables.ts
@@ -419,6 +419,9 @@ export interface PanelDef {
yMin?: number;
yMinRight?: number;
yMaxRight?: number;
+ /** Breathing room (in axis units) above / below the left-axis data range. */
+ yPadTop?: number;
+ yPadBottom?: number;
/** Whether the left axis should include zero (false for pressure) */
zeroBaseLeft: boolean;
hasPictograms: boolean;
@@ -496,6 +499,10 @@ export function buildPanelDef(
unit: leftKind ? unitForKind(leftKind, units) : '',
unitRight: rightKind ? unitForKind(rightKind, units) : undefined,
yMin: leftKind && isZeroBased(leftKind) ? 0 : undefined,
+ // temperature curves shouldn't touch the frame: guarantee headroom above
+ // the max and extra space below the min (extrema labels live there too)
+ yPadTop: leftKind === 'temp' ? 3 : undefined,
+ yPadBottom: leftKind === 'temp' ? 5 : undefined,
// temperature and pressure sit far from zero, so their axis is derived from
// the data range (a forced 0 baseline just wastes vertical space)
zeroBaseLeft: leftKind ? isZeroBased(leftKind) : true,