From c38a094a63e63e65e3649dcfc8dd305eaf141073 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 8 Dec 2021 19:58:03 +0000 Subject: [PATCH] :sparkles: Adds a weather forecast widget --- docs/widgets.md | 29 ++- src/components/Widgets/WeatherForecast.vue | 276 +++++++++++++++++++++ src/components/Widgets/WidgetBase.vue | 5 +- src/utils/defaults.js | 1 + 4 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 src/components/Widgets/WeatherForecast.vue diff --git a/docs/widgets.md b/docs/widgets.md index b7dab491..6e4f0486 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -53,12 +53,39 @@ A simple, live-updating local weather component, showing temperature, conditions icon: fas fa-clouds type: weather options: - apiKey: 6e29c7d514cf890f846d58178b6d418f + apiKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx city: London units: metric hideDetails: false ``` +### Weather Forecast + +Displays the weather (temperature and conditions) for the next few days for a given location. Note that this requires either the free [OpenWeatherMap Student Plan](https://home.openweathermap.org/students), or the Premium Plan. + +##### Options + +**Field** | **Type** | **Required** | **Description** +--- | --- | --- | --- +**`apiKey`** | `string` | Required | Your OpenWeatherMap API key. You can get one for free at [openweathermap.org](https://openweathermap.org/) +**`city`** | `string` | Required | A city name to use for fetching weather. This can also be a state code or country code, following the ISO-3166 format +**`numDays`** | `number` | _Optional_ | The number of days to display of forecast info to display. Defaults to `4`, max `16` days +**`units`** | `string` | _Optional_ | The units to use for displaying data, can be either `metric` or `imperial`. Defaults to `metric` +**`hideDetails`** | `boolean` | _Optional_ | If set to `true`, the additional details (wind, humidity, pressure, etc) will not be shown. Defaults to `false` + +##### Example + +```yaml +- name: Weather Forecast + icon: ':sunny:' + type: weather-forecast + options: + city: California + numDays: 6 + apiKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + units: imperial +``` + --- ## Dynamic Widgets diff --git a/src/components/Widgets/WeatherForecast.vue b/src/components/Widgets/WeatherForecast.vue new file mode 100644 index 00000000..d1d2003c --- /dev/null +++ b/src/components/Widgets/WeatherForecast.vue @@ -0,0 +1,276 @@ + + + + + diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue index 9b06dab0..3a0f5233 100644 --- a/src/components/Widgets/WidgetBase.vue +++ b/src/components/Widgets/WidgetBase.vue @@ -12,6 +12,7 @@ > + @@ -19,14 +20,16 @@