Moved Header from Home to App, and added check that data exists

This commit is contained in:
Alicia Sykes 2021-04-05 14:06:39 +01:00
parent 5ca3192992
commit 7f33be8485
5 changed files with 64 additions and 58 deletions

View File

@ -1,26 +1,38 @@
<template> <template>
<div id="app"> <div id="app">
<router-view/> <Header :pageInfo="getPageInfo(pageInfo)" />
<router-view />
<Footer /> <Footer />
</div> </div>
</template> </template>
<script> <script>
// const jsyaml = require("js-yaml"); import Header from '@/components/Header.vue';
import Footer from '@/components/Footer.vue'; import Footer from '@/components/Footer.vue';
// import defaultConfig from '../src/data/conf.yml'; import conf from '@/data/conf.yml';
export default { export default {
name: 'app', name: 'app',
components: { components: {
Header,
Footer, Footer,
}, },
// methods: { data: () => ({
// getConfig: async function () { pageInfo: conf.pageInfo,
// // const defaults = jsyaml.load(defaultConfig); }),
methods: {
// }, /* Returns either page info from the config, or default values */
// } getPageInfo(pageInfo) {
const defaults = { title: 'Demo', description: '' };
if (pageInfo) {
return {
title: pageInfo.title || defaults.title,
description: pageInfo.description || defaults.description,
};
}
return defaults;
},
},
}; };
</script> </script>

View File

@ -2,26 +2,13 @@
<el-tooltip placement="bottom" effect="dark" :content="description" :disabled="!description"> <el-tooltip placement="bottom" effect="dark" :content="description" :disabled="!description">
<a :href="url" :class="`item ${!icon? 'short': ''}`" v-on:click="$emit('itemClicked')" <a :href="url" :class="`item ${!icon? 'short': ''}`" v-on:click="$emit('itemClicked')"
tabindex="0" target="_blank" rel="noopener noreferrer"> tabindex="0" target="_blank" rel="noopener noreferrer">
<!-- Item Text -->
<div class="tile-title" :id="`tile-${id}`"> <div class="tile-title" :id="`tile-${id}`">
<span class="text">{{ title }}</span> <span class="text">{{ title }}</span>
<div class="overflow-dots">...</div> <div class="overflow-dots">...</div>
</div> </div>
<icon :icon="icon" :url="url" /> <!-- Item Icon -->
<!-- <img <Icon :icon="icon" :url="url" />
v-if="icon"
:src="getAppropriateImgPath(icon, url)"
class="tile-icon"
/> -->
<!-- <img
v-else-if="iconType === 'svg' && icon"
:src="`/img/item-icons/tile-svgs/${icon}.svg`"
class="tile-svg"
/> -->
<!-- <img
v-else-if="fontAwesome"
:src="`/img/tile-svgs/${svg}.svg`"
class="tile-svg"
/> -->
</a> </a>
</el-tooltip> </el-tooltip>
</template> </template>

View File

@ -88,5 +88,4 @@ export default {
width: 60px; width: 60px;
filter: drop-shadow(2px 4px 6px $transparent-black) saturate(0.65); filter: drop-shadow(2px 4px 6px $transparent-black) saturate(0.65);
} }
</style> </style>

View File

@ -1,6 +1,7 @@
import Vue from 'vue'; import Vue from 'vue';
import Router from 'vue-router'; import Router from 'vue-router';
import Home from './views/Home.vue'; import Home from './views/Home.vue';
import conf from './data/conf.yml'; // Main site configuration
Vue.use(Router); Vue.use(Router);
@ -10,6 +11,9 @@ const router = new Router({
path: '/', path: '/',
name: 'home', name: 'home',
component: Home, component: Home,
props: {
sections: conf.sections || [],
},
meta: { meta: {
title: 'Home Page', title: 'Home Page',
metaTags: [ metaTags: [

View File

@ -1,7 +1,5 @@
<template> <template>
<div class="home"> <div class="home">
<!-- Page title and navigation buttons -->
<Header :pageInfo="getPageInfo(pageInfo)" />
<!-- Search bar, layout options and settings --> <!-- Search bar, layout options and settings -->
<FilterTile ref="filterComp" <FilterTile ref="filterComp"
@user-is-searchin="searching" @user-is-searchin="searching"
@ -10,7 +8,7 @@
class="filter-container" class="filter-container"
/> />
<!-- Main content, section for each group of items --> <!-- Main content, section for each group of items -->
<div :class="`item-group-container orientation-${layout}`"> <div :class="`item-group-container orientation-${layout}`" v-if="checkTheresData(sections)">
<ItemGroup <ItemGroup
v-for="(section, index) in sections" v-for="(section, index) in sections"
:key="index" :key="index"
@ -21,26 +19,25 @@
@itemClicked="finishedSearching()" @itemClicked="finishedSearching()"
/> />
</div> </div>
<div v-else class="no-data">No Data Found Yet</div>
</div> </div>
</template> </template>
<script> <script>
import Header from '@/components/Header.vue';
import FilterTile from '@/components/FilterTile.vue'; import FilterTile from '@/components/FilterTile.vue';
import ItemGroup from '@/components/ItemGroup.vue'; import ItemGroup from '@/components/ItemGroup.vue';
import conf from '../data/conf.yml'; // Main site configuration
export default { export default {
name: 'home', name: 'home',
props: {
sections: Array, // Main site configuration
},
components: { components: {
Header,
FilterTile, FilterTile,
ItemGroup, ItemGroup,
}, },
data: () => ({ data: () => ({
pageInfo: conf.pageInfo, // Site meta data (title, description, etc)
sections: conf.sections, // List of sections, containing items
searchValue: '', searchValue: '',
layout: '', layout: '',
}), }),
@ -54,11 +51,9 @@ export default {
}, },
}, },
methods: { methods: {
setLayoutOrientation(layout) { /* Returns true if there is one or more sections in the config */
this.layoutOrientation = layout; checkTheresData(sections) {
}, return sections && sections.length >= 1;
getLayoutOrientation() {
return localStorage.layoutOrientation || 'default';
}, },
/* Updates local data with search value, triggered from filter comp */ /* Updates local data with search value, triggered from filter comp */
searching(searchValue) { searching(searchValue) {
@ -91,16 +86,13 @@ export default {
getDisplayData(section) { getDisplayData(section) {
return !section.displayData ? {} : section.displayData; return !section.displayData ? {} : section.displayData;
}, },
/* Returns either page info from the config, or default values */ /* Sets layout attribute, which is used by ItemGroup */
getPageInfo(pageInfo) { setLayoutOrientation(layout) {
const defaults = { title: 'Demo', description: '' }; this.layoutOrientation = layout;
if (pageInfo) { },
return { /* Either gets user's preferred layout from session, or returns default */
title: pageInfo.title || defaults.title, getLayoutOrientation() {
description: pageInfo.description || defaults.description, return localStorage.layoutOrientation || 'default';
};
}
return defaults;
}, },
/* Injects font-awesome's script tag, used for item icons */ /* Injects font-awesome's script tag, used for item icons */
initiateFontAwesome() { initiateFontAwesome() {
@ -123,6 +115,7 @@ export default {
.home { .home {
background: $background; background: $background;
padding-bottom: 1px; padding-bottom: 1px;
min-height: 90%;
} }
/* Outside container wrapping the item groups*/ /* Outside container wrapping the item groups*/
@ -157,4 +150,15 @@ export default {
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
} }
} }
.no-data {
font-size: 2rem;
color: $background;
background: #ffffffeb;
width: fit-content;
margin: 2rem auto;
padding: 0.5rem 1rem;
border-radius: 4px;
}
</style> </style>