🎨 Simplify toggling between views

This commit is contained in:
Kevin
2019-11-15 17:56:44 +01:00
parent 64d015b21b
commit 5388f2fe44
3 changed files with 31 additions and 10 deletions

13
components/CardsView.vue Normal file
View File

@@ -0,0 +1,13 @@
<template lang="pug">
.cards
Card(v-for='resource in category.resources' :resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
</template>
<script>
import Card from './Card'
export default {
components: { Card },
props: ['category', 'createCopyUrl', 'activeCard'],
}
</script>

13
components/TableView.vue Normal file
View File

@@ -0,0 +1,13 @@
<template lang="pug">
table
TableRow(v-for='resource in category.resources' :resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
</template>
<script>
import TableRow from '../components/TableRow'
export default {
components: { TableRow },
props: ['category', 'createCopyUrl', 'activeCard'],
}
</script>

View File

@@ -3,21 +3,16 @@
transition(name="fade-title" @after-enter="afterEnter")
h1(v-if="showTitle") {{ category.title }}
transition(name="fade-card")
.cards(v-if="areCardsVisible && showCards")
template(v-for='resource in category.resources' )
Card(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
transition(name="fade-card")
table(v-if="!areCardsVisible && showCards")
template(v-for='resource in category.resources' )
TableRow(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
div(v-if="showCards")
<component :is="areCardsVisible ? 'CardsView' : 'TableView'" :category="category" :createCopyUrl="createCopyUrl" :activeCard='activeCard'></component>
</template>
<script>
import Card from '../components/Card'
import TableRow from '../components/TableRow'
import CardsView from '../components/CardsView'
import TableView from '../components/TableView'
export default {
components: { Card, TableRow },
components: { CardsView, TableView },
data() {
return {
categoryRouteTitle: this.$route.params.category,