wayfarer-weather/components/ProviderPicker.tsx

35 lines
965 B
TypeScript
Raw Permalink Normal View History

2026-10-31 21:20:16 -05:00
"use client";
import { pixelLabel } from "@/lib/styles";
import type { ProviderId, ProviderInfo } from "@/lib/weather/types";
import { ChoiceChips } from "./ui/ChoiceChips";
/**
2026-10-31 21:50:28 -05:00
* Switcher between active weather data sources.
* Only configured providers are shown; hidden automatically if only one source is active.
2026-10-31 21:20:16 -05:00
*/
export function ProviderPicker({ providers, selected, onChange }: {
providers: ProviderInfo[];
selected: ProviderId;
onChange: (id: ProviderId) => void;
}) {
2026-10-31 21:50:28 -05:00
if (providers.length <= 1) return null;
2026-10-31 21:20:16 -05:00
return (
2026-10-31 21:50:28 -05:00
<div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5">
<span className={pixelLabel}>Source</span>
<ChoiceChips
legend="Weather data source"
size="sm"
selected={selected}
onChange={onChange}
choices={providers.map((p) => ({
value: p.id,
label: p.label,
note: `${p.forecastDays}d`,
}))}
/>
2026-10-31 21:20:16 -05:00
</div>
);
}