` to render results to the user. Again, how you do this will depend on the structure of your data, and what you want to display, but at it's simplest, it might look something like this:
+
+```vue
+{{ myResults }}
+```
+
+**Styling**
+Styles can be written your your widget within the `
+```
+
+For examples of finished widget components, see the [Widgets](https://github.com/Lissy93/dashy/tree/master/src/components/Widgets) directory. Specifically, the [`XkcdComic.vue`](https://github.com/Lissy93/dashy/blob/master/src/components/Widgets/XkcdComic.vue) widget is quite minimal, so would make a good example, as will [this example implementation](https://github.com/Lissy93/dashy/commit/3da76ce2999f57f76a97454c0276301e39957b8e).
+
+
+### Step 3 - Register
+
+Next, import and register your new widget, in [`WidgetBase.vue`](https://github.com/Lissy93/dashy/blob/master/src/components/Widgets/WidgetBase.vue). In this file, you'll need to add the following:
+
+Import your widget file
+```javascript
+import ExampleWidget from '@/components/Widgets/ExampleWidget.vue';
+```
+
+Then register the component
+```javascript
+components: {
+ ...
+ ExampleWidget,
+},
+```
+
+Finally, add the markup to render it. The only attribute you need to change here is, setting `widgetType === 'example'` to your widget's name.
+```vue
+
+```
+
+### Step 4 - Docs
+
+Finally, add some documentation for your widget in the [Widget Docs](https://github.com/Lissy93/dashy/blob/master/docs/widgets.md), so that others know hoe to use it. Include the following information: Title, short description, screenshot, config options and some example YAML.
+
+
+**Summary**: For a complete example of everything discussed here, see: [`3da76ce`](https://github.com/Lissy93/dashy/commit/3da76ce2999f57f76a97454c0276301e39957b8e)
diff --git a/docs/widgets.md b/docs/widgets.md
index 22795b48..d957a503 100644
--- a/docs/widgets.md
+++ b/docs/widgets.md
@@ -367,30 +367,6 @@ Displays airport departure and arrival flights, using data from [AeroDataBox](ht
---
-### Example Widget
-
-A simple example widget, to use as a template. Fetches and displays a list of images, from [Dummy APIs](https://dummyapis.com/).
-
-
-
-##### Options
-
-**Field** | **Type** | **Required** | **Description**
---- | --- | --- | ---
-**`text`** | `string` | _Optional_ | Text to display in the images. Defaults to `Dashy`
-**`count`** | `number` | _Optional_ | The number of images to be rendered. Defaults to `5`
-
-##### Example
-
-```yaml
-- type: example
- options:
- text: Hello
- count: 3
-```
-
----
-
## Dynamic Widgets
### Iframe Widget
@@ -445,3 +421,5 @@ Many websites and apps provide their own embeddable widgets. These can be used w
---
## Build your own Widget
+
+For a full tutorial on creating your own widget, you can follow [this guide](https://github.com/Lissy93/dashy/blob/master/docs/development-guides.md#building-a-widget), or take a look at [here](https://github.com/Lissy93/dashy/commit/3da76ce2999f57f76a97454c0276301e39957b8e) for a code example.
diff --git a/src/components/Widgets/ExampleWidget.vue b/src/components/Widgets/ExampleWidget.vue
deleted file mode 100644
index e4ffbcc7..00000000
--- a/src/components/Widgets/ExampleWidget.vue
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
{{ image.title }}
-
![]()
-
-
-
-
-
-
-
-
diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue
index 402a0ac1..abc81472 100644
--- a/src/components/Widgets/WidgetBase.vue
+++ b/src/components/Widgets/WidgetBase.vue
@@ -116,13 +116,6 @@
@error="handleError"
:ref="widgetRef"
/>
-
{{ handleError('No widget type was specified') }}
@@ -152,7 +145,6 @@ import Jokes from '@/components/Widgets/Jokes.vue';
import Flights from '@/components/Widgets/Flights.vue';
import IframeWidget from '@/components/Widgets/IframeWidget.vue';
import EmbedWidget from '@/components/Widgets/EmbedWidget.vue';
-import ExampleWidget from '@/components/Widgets/ExampleWidget.vue';
export default {
name: 'Widget',
@@ -175,7 +167,6 @@ export default {
Flights,
IframeWidget,
EmbedWidget,
- ExampleWidget,
},
props: {
widget: Object,
diff --git a/src/mixins/WidgetMixin.js b/src/mixins/WidgetMixin.js
index 7488fbd3..0e9cde85 100644
--- a/src/mixins/WidgetMixin.js
+++ b/src/mixins/WidgetMixin.js
@@ -1,6 +1,6 @@
/**
* Mixin that all pre-built and custom widgets extend from.
- * Manages loading state, error handling and data updates.
+ * Manages loading state, error handling, data updates and user options
*/
import ProgressBar from 'rsup-progress';
import ErrorHandler from '@/utils/ErrorHandler';
@@ -15,10 +15,15 @@ const WidgetMixin = {
data: () => ({
progress: new ProgressBar({ color: 'var(--progress-bar)' }),
}),
+ /* When component mounted, fetch initial data */
+ mounted() {
+ this.fetchData();
+ },
methods: {
/* Re-fetches external data, called by parent. Usually overridden by widget */
update() {
- console.log('No update method configured for this widget'); // eslint-disable-line no-console
+ this.startLoading();
+ this.fetchData();
},
/* Called when an error occurs. Logs to handler, and passes to parent component */
error(msg, stackTrace) {
@@ -35,6 +40,10 @@ const WidgetMixin = {
this.$emit('loading', false);
setTimeout(() => { this.progress.end(); }, 500);
},
+ /* Overridden by child component. Will make network request, then end loader */
+ fetchData() {
+ this.finishLoading();
+ },
},
};
diff --git a/src/utils/defaults.js b/src/utils/defaults.js
index 9886c08b..7434290b 100644
--- a/src/utils/defaults.js
+++ b/src/utils/defaults.js
@@ -216,7 +216,6 @@ module.exports = {
jokes: 'https://v2.jokeapi.dev/joke/',
flights: 'https://aerodatabox.p.rapidapi.com/flights/airports/icao/',
rssToJson: 'https://api.rss2json.com/v1/api.json',
- exampleEndpoint: 'https://hub.dummyapis.com/ImagesList',
},
/* URLs for web search engines */
searchEngineUrls: {