diff --git a/src/assets/interface-icons/widget-update.svg b/src/assets/interface-icons/widget-update.svg new file mode 100644 index 00000000..29e37fbe --- /dev/null +++ b/src/assets/interface-icons/widget-update.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue index 9c5a8d6f..5424bc19 100644 --- a/src/components/LinkItems/Section.vue +++ b/src/components/LinkItems/Section.vue @@ -12,11 +12,11 @@ @openContextMenu="openContextMenu" > -
{{ temp }}
@@ -65,6 +66,10 @@ export default { }, }, methods: { + /* Extends mixin, and updates data. Called by parent component */ + update() { + this.fetchWeather(); + }, /* Adds units symbol to temperature, depending on metric or imperial */ processTemp(temp) { return `${Math.round(temp)}${this.tempDisplayUnits}`; @@ -73,6 +78,7 @@ export default { fetchWeather() { axios.get(this.endpoint) .then((response) => { + this.loading = false; const { data } = response; this.icon = data.weather[0].icon; this.description = data.weather[0].description; @@ -141,6 +147,10 @@ export default { diff --git a/src/components/Widgets/WidgetError.vue b/src/components/Widgets/WidgetError.vue new file mode 100644 index 00000000..189624a0 --- /dev/null +++ b/src/components/Widgets/WidgetError.vue @@ -0,0 +1,18 @@ + + + + + + + diff --git a/src/components/Widgets/XkcdComic.vue b/src/components/Widgets/XkcdComic.vue index 99af5e59..3831f985 100644 --- a/src/components/Widgets/XkcdComic.vue +++ b/src/components/Widgets/XkcdComic.vue @@ -40,11 +40,18 @@ export default { } return 'latest'; }, + endpoint() { + return `${widgetApiEndpoints.xkcdComic}?comic=${this.comicNumber}`; + }, }, methods: { + /* Extends mixin, and updates data. Called by parent component */ + update() { + this.fetchData(); + }, /* Make GET request to CoinGecko API endpoint */ fetchData() { - axios.get(`${widgetApiEndpoints.xkcdComic}?comic=${this.comicNumber}`) + axios.get(this.endpoint) .then((response) => { this.processData(response.data); }) diff --git a/src/mixins/WidgetMixin.js b/src/mixins/WidgetMixin.js index 7d91a295..4dcbeb12 100644 --- a/src/mixins/WidgetMixin.js +++ b/src/mixins/WidgetMixin.js @@ -1,10 +1,31 @@ +import LoadingAnimation from '@/assets/interface-icons/loader.svg'; + const WidgetMixin = { + components: { + LoadingAnimation, + }, props: { + /* The options prop is an object of settings for a given widget */ options: { type: Object, default: {}, }, }, + data: () => ({ + loading: true, // Indicates current loading status, to display spinner + }), + methods: { + /* Overridden by widget component. Re-fetches and renders any external data * + * Called by parent component, and triggered either by user or time interval */ + update() { + // eslint-disable-next-line no-console + console.log('No update method configured for this widget'); + }, + }, + mounted() { + // If the mounted function isn't overridden,then hide loader + this.loading = false; + }, }; export default WidgetMixin; diff --git a/src/styles/color-themes.scss b/src/styles/color-themes.scss index c6220cf1..a1556d1e 100644 --- a/src/styles/color-themes.scss +++ b/src/styles/color-themes.scss @@ -331,6 +331,9 @@ html[data-theme='colorful'] { div.context-menu { border-color: var(--primary); } + .collapsable.is-open { + height: -webkit-fill-available; + } } html[data-theme='minimal-light'], html[data-theme='minimal-dark'], html[data-theme='vaporware'] { diff --git a/src/views/Home.vue b/src/views/Home.vue index 92a32f31..bdbc831c 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -28,23 +28,25 @@ + (this.colCount ? `col-count-${this.colCount} ` : '')" > -