From ebd4c483008b6133df8394b1ff13558531141c2c Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 11 Dec 2021 18:50:11 +0000 Subject: [PATCH] :sparkles: Develops a crypto price chart widget --- docs/widgets.md | 31 +++- src/components/Widgets/CryptoPriceChart.vue | 182 ++++++++++++++++++++ src/components/Widgets/WidgetBase.vue | 3 + 3 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 src/components/Widgets/CryptoPriceChart.vue diff --git a/docs/widgets.md b/docs/widgets.md index 83accd78..86465ca8 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -86,6 +86,30 @@ Displays the weather (temperature and conditions) for the next few days for a gi units: imperial ``` +### Crypto Token Price History + +Shows recent price history for a given crypto asset, using price data fetched from [CoinGecko](https://www.coingecko.com/) + +##### Options + +**Field** | **Type** | **Required** | **Description** +--- | --- | --- | --- +**`asset`** | `string` | Required | Name of a crypto asset, coin or token to fetch price data for +**`currency`** | `string` | _Optional_ | The fiat currency to display results in, expressed as an ISO-4217 alpha code (see [list of currencies](https://www.iban.com/currency-codes)). Defaults to `USD` +**`numDays`** | `number` | _Optional_ | The number of days of price history to render. Defaults to `7`, min: `1`, max: `30` days + +##### Example + +```yaml +- name: Bitcoin Price + icon: fab fa-bitcoin + type: crypto-price-chart + options: + asset: bitcoin + currency: GBP + numDays: 7 +``` + ### TFL Status Shows real-time tube status of the London Underground. All options are optional. @@ -101,7 +125,12 @@ Shows real-time tube status of the London Underground. All options are optional. ##### Example ```yaml - - name: TFL Status +- name: London Underground + type: tfl-status +``` + +```yaml + - name: Commute icon: '🚋' type: tfl-status options: diff --git a/src/components/Widgets/CryptoPriceChart.vue b/src/components/Widgets/CryptoPriceChart.vue new file mode 100644 index 00000000..ac1e3559 --- /dev/null +++ b/src/components/Widgets/CryptoPriceChart.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue index f466ffc0..ad55984e 100644 --- a/src/components/Widgets/WidgetBase.vue +++ b/src/components/Widgets/WidgetBase.vue @@ -14,6 +14,7 @@ + @@ -23,6 +24,7 @@ import Clock from '@/components/Widgets/Clock.vue'; import Weather from '@/components/Widgets/Weather.vue'; import WeatherForecast from '@/components/Widgets/WeatherForecast.vue'; import TflStatus from '@/components/Widgets/TflStatus.vue'; +import CryptoPriceChart from '@/components/Widgets/CryptoPriceChart.vue'; import Collapsable from '@/components/LinkItems/Collapsable.vue'; export default { @@ -33,6 +35,7 @@ export default { Weather, WeatherForecast, TflStatus, + CryptoPriceChart, }, props: { widget: Object,