import type { Trip, Weather, HourlyWeather } from "../../lib/types";
function tempColor(temp: number): string {
if (temp >= 30) return "var(--error)";
if (temp >= 25) return "var(--warning)";
if (temp >= 18) return "var(--success)";
if (temp >= 12) return "var(--info)";
return "var(--info-light)";
}
function HourRow({ h }: { h: HourlyWeather }) {
const color = tempColor(h.temp);
return (
{h.time}
{h.temp}°
{h.feelsLike != null && h.feelsLike !== h.temp && (
feels {h.feelsLike}°
)}
{h.location}
{h.conditions}{h.wind ? ` · ${h.wind}` : ""}
{h.note &&
{h.note}
}
);
}
function DayWeather({ wx, dayLabel }: { wx: Weather; dayLabel: string }) {
const dateStr = new Date(wx.date + "T12:00:00").toLocaleDateString("en-US", {
weekday: "short", month: "short", day: "numeric",
});
return (
{wx.high}°
/
{wx.low}°
{wx.conditions}
Sunrise {wx.sunrise} · Sunset {wx.sunset}
{wx.hourly && wx.hourly.length > 0 && (
{wx.hourly.map((h, i) => (
))}
)}
);
}
export function WeatherTab({ trip }: { trip: Trip }) {
return (
{trip.weather.map((wx, i) => (
))}
);
}