import { formatClock, formatShortDate } from "@/lib/display"; import { pixelLabel } from "@/lib/styles"; import type { AlertSeverity, WeatherAlert } from "@/lib/weather/types"; import { Slot } from "./Slot"; const SEVERITY_TEXT: Record = { extreme: "text-heart", severe: "text-heart", moderate: "text-gold-bright", minor: "text-ink", unknown: "text-ink", }; /** Active weather alerts. Each one opens to show the full text and instructions. */ export function AlertsBanner({ alerts, source, timeZone }: { alerts: WeatherAlert[]; source: string | null; timeZone: string | null }) { if (alerts.length === 0) return null; const when = (iso: string | null) => (iso ? `${formatShortDate(iso, timeZone)}, ${formatClock(iso, timeZone)}` : null); return (

{alerts.length === 1 ? "1 active alert" : `${alerts.length} active alerts`}

{alerts.map((alert, i) => (
{alert.title}

{[alert.source, when(alert.starts) && `from ${when(alert.starts)}`, when(alert.ends) && `until ${when(alert.ends)}`] .filter(Boolean) .join(" · ")}

{alert.description}

{alert.instruction &&

{alert.instruction}

}
))}

{source ? `Alerts from ${source} · ` : ""}Follow official local emergency guidance for life-safety decisions.

); }