Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add formatting options to weather widgets #3093

Merged
merged 3 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add format for weatherapi also
  • Loading branch information
benphelps committed Mar 10, 2024
commit be757a96ec9fa1ae8eb7a8cde87f289b242ef7e3
2 changes: 2 additions & 0 deletions docs/widgets/info/weather.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The free tier is all that's required, you will need to [register](https://www.we
units: metric # or imperial
apiKey: yourweatherapikey
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).
1 change: 1 addition & 0 deletions src/components/widgets/weather/weather.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Widget({ options }) {
value: options.units === "metric" ? data.current.temp_c : data.current.temp_f,
style: "unit",
unit,
...options.format,
})}
</PrimaryText>
<SecondaryText>{data.current.condition.text}</SecondaryText>
Expand Down