feat(weather-widget): add imperial windspeed option (#4253)
This commit is contained in:
1 parent
6d0a1452a6
commit
50a23d76e3
6 files changed
+44
-6
No files matched your search
@@ -7,6 +7,7 @@ import dayjs from "dayjs";
|
||||
|
||||
import type { RouterOutputs } from "@homarr/api";
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { metricToImperial } from "@homarr/common";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
|
||||
import type { WidgetComponentProps } from "../definition";
|
||||
@@ -52,6 +53,7 @@ interface WeatherProps extends Pick<WidgetComponentProps<"weather">, "options">
|
||||
|
||||
const DailyWeather = ({ options, weather }: WeatherProps) => {
|
||||
const t = useScopedI18n("widget.weather");
|
||||
const tCommon = useScopedI18n("common");
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -78,7 +80,17 @@ const DailyWeather = ({ options, weather }: WeatherProps) => {
|
||||
{options.showCurrentWindSpeed && (
|
||||
<Group className="weather-current-wind-speed-group" wrap="nowrap" gap="xs">
|
||||
<IconWind size={16} />
|
||||
<Text fz={16}>{t("currentWindSpeed", { currentWindSpeed: String(weather.current.windspeed) })}</Text>
|
||||
<Text fz={16}>
|
||||
{t("currentWindSpeed", {
|
||||
currentWindSpeed: (options.useImperialSpeed
|
||||
? metricToImperial(weather.current.windspeed)
|
||||
: weather.current.windspeed
|
||||
).toFixed(1),
|
||||
unit: options.useImperialSpeed
|
||||
? tCommon("unit.speed.milesPerHour")
|
||||
: tCommon("unit.speed.kilometersPerHour"),
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
)}
|
||||
<Group className="weather-max-min-temp-group" wrap="nowrap" gap="sm">
|
||||
@@ -180,6 +192,7 @@ function Forecast({ weather, options }: WeatherProps) {
|
||||
</HoverCard.Target>
|
||||
<HoverCard.Dropdown>
|
||||
<WeatherDescription
|
||||
useImperialSpeed={options.useImperialSpeed}
|
||||
dateFormat={dateFormat}
|
||||
time={dayWeather.time}
|
||||
weatherCode={dayWeather.weatherCode}
|
||||
|
||||
Reference in new issue
Block a user