mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Enhancement: Add formatting options to weather widgets (#3093)
This commit is contained in:
parent
83d1ea5ec4
commit
b5258c5200
@ -13,6 +13,8 @@ No registration is required at all! See [https://open-meteo.com/en/docs](https:/
|
|||||||
timezone: Europe/Kiev # optional
|
timezone: Europe/Kiev # optional
|
||||||
units: metric # or imperial
|
units: metric # or imperial
|
||||||
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
||||||
|
format: # optional, Intl.NumberFormat options
|
||||||
|
maximumFractionDigits: 1
|
||||||
```
|
```
|
||||||
|
|
||||||
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
||||||
|
@ -14,6 +14,8 @@ The free tier "One Call API" is all that's required, you will need to [subscribe
|
|||||||
provider: openweathermap
|
provider: openweathermap
|
||||||
apiKey: youropenweathermapkey # required only if not using provider, this reveals api key in requests
|
apiKey: youropenweathermapkey # required only if not using provider, this reveals api key in requests
|
||||||
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
||||||
|
format: # optional, Intl.NumberFormat options
|
||||||
|
maximumFractionDigits: 1
|
||||||
```
|
```
|
||||||
|
|
||||||
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
||||||
|
@ -15,6 +15,8 @@ The free tier is all that's required, you will need to [register](https://www.we
|
|||||||
units: metric # or imperial
|
units: metric # or imperial
|
||||||
apiKey: yourweatherapikey
|
apiKey: yourweatherapikey
|
||||||
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
cache: 5 # Time in minutes to cache API responses, to stay within limits
|
||||||
|
format: # optional, Intl.NumberFormat options
|
||||||
|
maximumFractionDigits: 1
|
||||||
```
|
```
|
||||||
|
|
||||||
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
You can optionally not pass a `latitude` and `longitude` and the widget will use your current location (requires a secure context, eg. HTTPS).
|
||||||
|
@ -46,6 +46,7 @@ function Widget({ options }) {
|
|||||||
value: data.current_weather.temperature,
|
value: data.current_weather.temperature,
|
||||||
style: "unit",
|
style: "unit",
|
||||||
unit,
|
unit,
|
||||||
|
...options.format,
|
||||||
})}
|
})}
|
||||||
</PrimaryText>
|
</PrimaryText>
|
||||||
<SecondaryText>{t(`wmo.${data.current_weather.weathercode}-${timeOfDay}`)}</SecondaryText>
|
<SecondaryText>{t(`wmo.${data.current_weather.weathercode}-${timeOfDay}`)}</SecondaryText>
|
||||||
|
@ -42,7 +42,7 @@ function Widget({ options }) {
|
|||||||
<Container options={options} additionalClassNames="information-widget-openweathermap">
|
<Container options={options} additionalClassNames="information-widget-openweathermap">
|
||||||
<PrimaryText>
|
<PrimaryText>
|
||||||
{options.label && `${options.label}, `}
|
{options.label && `${options.label}, `}
|
||||||
{t("common.number", { value: data.main.temp, style: "unit", unit })}
|
{t("common.number", { value: data.main.temp, style: "unit", unit, ...options.format })}
|
||||||
</PrimaryText>
|
</PrimaryText>
|
||||||
<SecondaryText>{data.weather[0].description}</SecondaryText>
|
<SecondaryText>{data.weather[0].description}</SecondaryText>
|
||||||
<WidgetIcon icon={mapIcon(condition, timeOfDay)} size="xl" />
|
<WidgetIcon icon={mapIcon(condition, timeOfDay)} size="xl" />
|
||||||
|
@ -45,6 +45,7 @@ function Widget({ options }) {
|
|||||||
value: options.units === "metric" ? data.current.temp_c : data.current.temp_f,
|
value: options.units === "metric" ? data.current.temp_c : data.current.temp_f,
|
||||||
style: "unit",
|
style: "unit",
|
||||||
unit,
|
unit,
|
||||||
|
...options.format,
|
||||||
})}
|
})}
|
||||||
</PrimaryText>
|
</PrimaryText>
|
||||||
<SecondaryText>{data.current.condition.text}</SecondaryText>
|
<SecondaryText>{data.current.condition.text}</SecondaryText>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user