diff --git a/src/components/FilterTile.vue b/src/components/FilterTile.vue
index a4631dc2..12500f60 100644
--- a/src/components/FilterTile.vue
+++ b/src/components/FilterTile.vue
@@ -15,14 +15,19 @@
@click="clearFilterInput">
+
+
+
+
@@ -31,6 +36,7 @@
+
+
diff --git a/src/utils/ThemeHelper.js b/src/utils/ThemeHelper.js
new file mode 100644
index 00000000..5d5bbbcc
--- /dev/null
+++ b/src/utils/ThemeHelper.js
@@ -0,0 +1,38 @@
+/**
+ * A function for pre-loading, and easy switching of external stylesheets
+ */
+const ThemeHelper = function th() {
+ /* Preload content, to avoid FOUC */
+ const preloadTheme = (href) => {
+ const link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = href;
+ document.head.appendChild(link);
+ return new Promise((resolve, reject) => {
+ link.onload = e => {
+ const { sheet } = e.target;
+ sheet.disabled = true;
+ resolve(sheet);
+ };
+ link.onerror = reject;
+ });
+ };
+
+ const selectTheme = (themes, name) => {
+ const themeResults = themes;
+ if (name && !themes[name]) {
+ throw new Error(`'${name}' has not been defined as a theme.`);
+ }
+ Object.keys(themeResults).forEach(n => { themeResults[n].disabled = (n !== name); });
+ };
+
+ const themes = {};
+
+ return {
+ add(name, href) { return preloadTheme(href).then(s => { themes[name] = s; }); },
+ set theme(name) { selectTheme(themes, name); },
+ get theme() { return Object.keys(themes).find(n => !themes[n].disabled); },
+ };
+};
+
+export default ThemeHelper;
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 8d0fcf65..dc4271e7 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -5,6 +5,7 @@
@user-is-searchin="searching"
@change-display-layout="setLayoutOrientation"
:displayLayout="layout"
+ :availableThemes="getAvailibleThemes()"
class="filter-container"
/>
@@ -31,7 +32,8 @@ import ItemGroup from '@/components/ItemGroup.vue';
export default {
name: 'home',
props: {
- sections: Array, // Main site configuration
+ sections: Array, // Main site content
+ appConfig: Object, // Main site configuation (optional)
},
components: {
FilterTile,
@@ -94,6 +96,24 @@ export default {
getLayoutOrientation() {
return localStorage.layoutOrientation || 'default';
},
+ getAvailibleThemes() {
+ const availibleThemes = {};
+ if (this.appConfig) {
+ if (this.appConfig.externalStyleSheet) {
+ const externals = this.appConfig.externalStyleSheet;
+ console.log(externals);
+ if (Array.isArray(externals)) {
+ externals.forEach((ext, i) => {
+ availibleThemes[`External Stylesheet ${i + 1}`] = ext;
+ });
+ } else {
+ availibleThemes['External Stylesheet'] = this.appConfig.externalStyleSheet;
+ }
+ }
+ }
+ availibleThemes.Deafault = '#';
+ return availibleThemes;
+ },
/* Checks if any of the icons are Font Awesome glyphs */
checkIfFontAwesomeNeeded() {
let isFound = false;
@@ -125,7 +145,7 @@ export default {
@import '../../src/styles/media-queries.scss';
.home {
- background: $background;
+ background: var(--background);
padding-bottom: 1px;
min-height: 90%;
}